From fdfea09dd7410d6ed7ad54df1ba3092bd0eecb92 Mon Sep 17 00:00:00 2001 From: Pierre Ducroquet Date: Wed, 24 Jan 2018 22:28:34 +0100 Subject: [PATCH] Allow building with LLVM 5.0 --- src/backend/lib/llvmjit_wrap.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/backend/lib/llvmjit_wrap.cpp b/src/backend/lib/llvmjit_wrap.cpp index b745aec4fe..7961148a85 100644 --- a/src/backend/lib/llvmjit_wrap.cpp +++ b/src/backend/lib/llvmjit_wrap.cpp @@ -29,7 +29,6 @@ extern "C" #include "llvm-c/Core.h" #include "llvm-c/BitReader.h" -#include "llvm-c/DebugInfo.h" #include #include @@ -50,6 +49,7 @@ extern "C" #include "llvm/Analysis/ModuleSummaryAnalysis.h" #include "llvm/Bitcode/BitcodeReader.h" #include "llvm/IR/CallSite.h" +#include "llvm/IR/DebugInfo.h" #include "llvm/IR/IntrinsicInst.h" #include "llvm/IR/ModuleSummaryIndex.h" #include "llvm/Linker/IRMover.h" @@ -218,6 +218,13 @@ llvm_inline(LLVMModuleRef M) llvm_execute_inline_plan(mod, globalsToInline.get()); } + +inline llvm::GlobalValueSummary *GlobalValueSummary__getBaseObject(llvm::GlobalValueSummary *gvs) { + if (auto *AS = llvm::dyn_cast(gvs)) + return &AS->getAliasee(); + return gvs; +} + /* * Build information necessary for inlining external function references in * mod. @@ -282,7 +289,7 @@ llvm_build_inline_plan(llvm::Module *mod) const llvm::Module *defMod; llvm::Function *funcDef; - fs = llvm::cast(gvs->getBaseObject()); + fs = llvm::cast(GlobalValueSummary__getBaseObject(gvs.get())); elog(DEBUG2, "func %s might be in %s", funcName.data(), modPath.data()); @@ -476,7 +483,7 @@ load_module(llvm::StringRef Identifier) * code. Until that changes, not much point in wasting memory and cycles * on processing debuginfo. */ - LLVMStripModuleDebugInfo(mod); + llvm::StripDebugInfo(*llvm::unwrap(mod)); return std::unique_ptr(llvm::unwrap(mod)); } -- 2.15.1