fix LLVM7.0 build (#2578)

This commit is contained in:
Johan Engelen 2018-02-18 22:07:01 +01:00 committed by Ivan Butygin
parent effce1723d
commit aa979e6e90
4 changed files with 28 additions and 7 deletions

View file

@ -339,7 +339,11 @@ void calculateModuleHash(llvm::Module *m, llvm::SmallString<32> &str) {
outputIR2ObjRelevantCmdlineArgs(hash_os);
outputIR2ObjRelevantEnvironmentOpts(hash_os);
#if LDC_LLVM_VER >= 700
llvm::WriteBitcodeToFile(*m, hash_os);
#else
llvm::WriteBitcodeToFile(m, hash_os);
#endif
hash_os.resultAsString(str);
IF_LOG Logger::println("Module's LLVM bitcode hash is: %s", str.c_str());
}

View file

@ -354,6 +354,13 @@ void writeModule(llvm::Module *m, const char *filename) {
errinfo.message().c_str());
fatal();
}
#if LDC_LLVM_VER >= 700
auto &M = *m;
#else
auto M = m;
#endif
if (opts::isUsingThinLTO()) {
#if LDC_LLVM_VER >= 309
Logger::println("Creating module summary for ThinLTO");
@ -372,11 +379,11 @@ void writeModule(llvm::Module *m, const char *filename) {
*m, /* function freq callback */ nullptr, &PSI);
#endif
llvm::WriteBitcodeToFile(m, bos, true, &moduleSummaryIndex,
llvm::WriteBitcodeToFile(M, bos, true, &moduleSummaryIndex,
/* generate ThinLTO hash */ true);
#endif
} else {
llvm::WriteBitcodeToFile(m, bos);
llvm::WriteBitcodeToFile(M, bos);
}
}

View file

@ -657,7 +657,11 @@ void setupModuleBitcodeData(const llvm::Module &srcModule, IRState *irs,
llvm::SmallString<1024> str;
llvm::raw_svector_ostream os(str);
#if LDC_LLVM_VER >= 700
llvm::WriteBitcodeToFile(srcModule, os);
#else
llvm::WriteBitcodeToFile(&srcModule, os);
#endif
auto runtimeCompiledIr = new llvm::GlobalVariable(
irs->module, llvm::Type::getInt8PtrTy(irs->context()), true,
@ -724,7 +728,12 @@ void generateBitcodeForDynamicCompile(IRState *irs) {
llvm::ValueToValueMapTy unused;
auto newModule = llvm::CloneModule(
&irs->module, unused, [&](const llvm::GlobalValue *val) -> bool {
#if LDC_LLVM_VER >= 700
irs->module,
#else
&irs->module,
#endif
unused, [&](const llvm::GlobalValue *val) -> bool {
// We don't dereference here, so const_cast should be safe
auto it = filter.find(const_cast<llvm::GlobalValue *>(val));
return filter.end() != it &&

View file

@ -188,10 +188,11 @@ public:
#if LDC_LLVM_VER >= 700
execSession(stringPool), resolver(createResolver()),
objectLayer(execSession,
[](llvm::orc::VModuleKey) {
return std::make_shared<llvm::SectionMemoryManager>();
},
[this](llvm::orc::VModuleKey) { return resolver; }),
[this](llvm::orc::VModuleKey) {
return llvm::orc::RTDyldObjectLinkingLayer::Resources{
std::make_shared<llvm::SectionMemoryManager>(),
resolver};
}),
#else
objectLayer(
[]() { return std::make_shared<llvm::SectionMemoryManager>(); }),