Skip to content

Commit

Permalink
[Misc] update llvm version to 13
Browse files Browse the repository at this point in the history
  • Loading branch information
LFsWang committed Nov 24, 2021
1 parent c4413c3 commit b1ca5cf
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 5 deletions.
3 changes: 1 addition & 2 deletions include/soll/AST/Decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ class Decl {
friend class ASTReader;

protected:
Decl(SourceRange L,
llvm::StringRef Name = llvm::StringRef::withNullAsEmpty(nullptr),
Decl(SourceRange L, llvm::StringRef Name = llvm::StringRef(""),
Visibility vis = Visibility::Default)
: Location(L), Name(Name.str()), Vis(vis), UniqueName(Name.str()) {}

Expand Down
15 changes: 14 additions & 1 deletion lib/CodeGen/BackendUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ void EmitAssemblyHelper::EmitAssembly(
TheModule->setDataLayout(TM->createDataLayout());
}

#if LLVM_VERSION_MAJOR >= 12
#if LLVM_VERSION_MAJOR >= 13
llvm::PassBuilder PB(TM.get(), llvm::PipelineTuningOptions(), llvm::None);
#elif LLVM_VERSION_MAJOR >= 12
llvm::PassBuilder PB(false, TM.get(), llvm::PipelineTuningOptions(),
llvm::None);
#elif LLVM_VERSION_MAJOR >= 9
Expand All @@ -152,10 +154,17 @@ void EmitAssemblyHelper::EmitAssembly(
llvm::PassBuilder PB(TM.get(), llvm::None);
#endif

#if LLVM_VERSION_MAJOR >= 13
llvm::LoopAnalysisManager LAM;
llvm::FunctionAnalysisManager FAM;
llvm::CGSCCAnalysisManager CGAM;
llvm::ModuleAnalysisManager MAM;
#else
llvm::LoopAnalysisManager LAM(false);
llvm::FunctionAnalysisManager FAM(false);
llvm::CGSCCAnalysisManager CGAM(false);
llvm::ModuleAnalysisManager MAM(false);
#endif

// Register the AA manager first so that our version is the one used.
FAM.registerPass([&] { return PB.buildDefaultAAPipeline(); });
Expand All @@ -177,7 +186,11 @@ void EmitAssemblyHelper::EmitAssembly(
PB.registerLoopAnalyses(LAM);
PB.crossRegisterProxies(LAM, FAM, CGAM, MAM);

#if LLVM_VERSION_MAJOR >= 13
llvm::ModulePassManager MPM;
#else
llvm::ModulePassManager MPM(false);
#endif

if (TargetOpts.BackendTarget == EWASM) {
MPM.addPass(LoweringInteger());
Expand Down
12 changes: 11 additions & 1 deletion lib/Frontend/ASTConsumers/ASTPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
#include "soll/AST/AST.h"
#include "soll/AST/ASTConsumer.h"
#include "soll/Frontend/ASTConsumers.h"
#if LLVM_VERSION_MAJOR >= 13
#include <llvm/ADT/StringExtras.h>
#endif
#include <llvm/ADT/Twine.h>
#include <llvm/Support/raw_ostream.h>

namespace {

std::string ToString(soll::UnaryOperatorKind op) {
Expand Down Expand Up @@ -136,7 +138,11 @@ std::string ToString(soll::TypePtr type) {
return llvm::Twine(ToString(at->getElementType()) + "[" +
(at->isDynamicSized()
? ""
#if LLVM_VERSION_MAJOR >= 13
: toString(at->getLength(), 10, false)) +
#else
: at->getLength().toString(10, false)) +
#endif
"]")
.str();
}
Expand Down Expand Up @@ -495,7 +501,11 @@ void ASTPrinter::visit(NumberLiteralType &literal) {
const bool Signed =
dynamic_cast<IntegerType *>(literal.getType().get())->isSigned();
os() << indent() << "NumberLiteral "
#if LLVM_VERSION_MAJOR >= 13
<< toString(literal.getValue(), 10, Signed) << "\n";
#else
<< literal.getValue().toString(10, Signed) << "\n";
#endif
ConstStmtVisitor::visit(literal);
unindent();
}
Expand Down
7 changes: 6 additions & 1 deletion lib/Frontend/CompilerInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,12 @@ std::unique_ptr<llvm::raw_pwrite_stream> CompilerInstance::createOutputFile(
OSFile = OutFile;
OS.reset(new llvm::raw_fd_ostream(
OSFile, Error,
(Binary ? llvm::sys::fs::F_None : llvm::sys::fs::F_Text)));
#if LLVM_VERSION_MAJOR >= 13
(Binary ? llvm::sys::fs::OF_None : llvm::sys::fs::OF_Text)
#else
(Binary ? llvm::sys::fs::F_None : llvm::sys::fs::F_Text)
#endif
));
if (Error)
return nullptr;
}
Expand Down

0 comments on commit b1ca5cf

Please sign in to comment.