From b1ca5cf95e0fbc2ee9c917be1fbc6d3cf50d6693 Mon Sep 17 00:00:00 2001 From: Sylveon Date: Wed, 24 Nov 2021 02:42:15 +0800 Subject: [PATCH] [Misc] update llvm version to 13 --- include/soll/AST/Decl.h | 3 +-- lib/CodeGen/BackendUtil.cpp | 15 ++++++++++++++- lib/Frontend/ASTConsumers/ASTPrinter.cpp | 12 +++++++++++- lib/Frontend/CompilerInstance.cpp | 7 ++++++- 4 files changed, 32 insertions(+), 5 deletions(-) diff --git a/include/soll/AST/Decl.h b/include/soll/AST/Decl.h index 5554e8d9..cc1728d4 100644 --- a/include/soll/AST/Decl.h +++ b/include/soll/AST/Decl.h @@ -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()) {} diff --git a/lib/CodeGen/BackendUtil.cpp b/lib/CodeGen/BackendUtil.cpp index 60d3e8ed..dd84c9de 100644 --- a/lib/CodeGen/BackendUtil.cpp +++ b/lib/CodeGen/BackendUtil.cpp @@ -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 @@ -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(); }); @@ -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()); diff --git a/lib/Frontend/ASTConsumers/ASTPrinter.cpp b/lib/Frontend/ASTConsumers/ASTPrinter.cpp index eda09b83..a48dba92 100644 --- a/lib/Frontend/ASTConsumers/ASTPrinter.cpp +++ b/lib/Frontend/ASTConsumers/ASTPrinter.cpp @@ -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 +#endif #include #include - namespace { std::string ToString(soll::UnaryOperatorKind op) { @@ -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(); } @@ -495,7 +501,11 @@ void ASTPrinter::visit(NumberLiteralType &literal) { const bool Signed = dynamic_cast(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(); } diff --git a/lib/Frontend/CompilerInstance.cpp b/lib/Frontend/CompilerInstance.cpp index 75aaec7d..68d1d36e 100644 --- a/lib/Frontend/CompilerInstance.cpp +++ b/lib/Frontend/CompilerInstance.cpp @@ -278,7 +278,12 @@ std::unique_ptr 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; }