Adapt jit-rt to LLVM 9

This commit is contained in:
Martin Kinkelin 2019-09-21 01:45:00 +02:00
parent 030123410a
commit 0ab79c1950
3 changed files with 14 additions and 1 deletions

View file

@ -53,8 +53,13 @@ if(LDC_DYNAMIC_COMPILE)
# to do find_package(LLVM CONFIG) for it so here is a hackish way to get it # to do find_package(LLVM CONFIG) for it so here is a hackish way to get it
include("${LLVM_CMAKEDIR}/LLVMConfig.cmake") include("${LLVM_CMAKEDIR}/LLVMConfig.cmake")
include("${LLVM_CMAKEDIR}/LLVM-Config.cmake") include("${LLVM_CMAKEDIR}/LLVM-Config.cmake")
set(asmprinter "asmprinter")
if(LDC_LLVM_VER LESS 900)
set(asmprinter "${LLVM_NATIVE_ARCH}asmprinter")
endif()
llvm_map_components_to_libnames(JITRT_LLVM_LIBS core support irreader executionengine passes nativecodegen orcjit target llvm_map_components_to_libnames(JITRT_LLVM_LIBS core support irreader executionengine passes nativecodegen orcjit target
"${LLVM_NATIVE_ARCH}disassembler" "${LLVM_NATIVE_ARCH}asmprinter") "${LLVM_NATIVE_ARCH}disassembler" "${asmprinter}")
foreach(libname ${JITRT_LLVM_LIBS}) foreach(libname ${JITRT_LLVM_LIBS})
unset(JITRT_TEMP_LIB CACHE) unset(JITRT_TEMP_LIB CACHE)

View file

@ -323,7 +323,13 @@ void disassemble(const llvm::TargetMachine &tm,
if (object.section_end() != secIt) { if (object.section_end() != secIt) {
const auto sec = *secIt; const auto sec = *secIt;
llvm::StringRef data; llvm::StringRef data;
#if LDC_LLVM_VER >= 900
auto dataOrError = sec.getContents();
assert(dataOrError);
data = *dataOrError;
#else
sec.getContents(data); sec.getContents(data);
#endif
if (llvm::object::SymbolRef::ST_Function == if (llvm::object::SymbolRef::ST_Function ==
llvm::cantFail(symbol.getType())) { llvm::cantFail(symbol.getType())) {

View file

@ -138,7 +138,9 @@ void addOptimizationPasses(llvm::legacy::PassManagerBase &mpm,
builder.Inliner = llvm::createAlwaysInlinerPass(); builder.Inliner = llvm::createAlwaysInlinerPass();
#endif #endif
} }
#if LDC_LLVM_VER < 900
builder.DisableUnitAtATime = false; builder.DisableUnitAtATime = false;
#endif
builder.DisableUnrollLoops = (disableLoopUnrolling.getNumOccurrences() > 0) builder.DisableUnrollLoops = (disableLoopUnrolling.getNumOccurrences() > 0)
? disableLoopUnrolling ? disableLoopUnrolling