mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-06 10:57:35 +03:00
fix LLVM7.0 build (#2578)
This commit is contained in:
parent
effce1723d
commit
aa979e6e90
4 changed files with 28 additions and 7 deletions
|
@ -339,7 +339,11 @@ void calculateModuleHash(llvm::Module *m, llvm::SmallString<32> &str) {
|
||||||
outputIR2ObjRelevantCmdlineArgs(hash_os);
|
outputIR2ObjRelevantCmdlineArgs(hash_os);
|
||||||
outputIR2ObjRelevantEnvironmentOpts(hash_os);
|
outputIR2ObjRelevantEnvironmentOpts(hash_os);
|
||||||
|
|
||||||
|
#if LDC_LLVM_VER >= 700
|
||||||
|
llvm::WriteBitcodeToFile(*m, hash_os);
|
||||||
|
#else
|
||||||
llvm::WriteBitcodeToFile(m, hash_os);
|
llvm::WriteBitcodeToFile(m, hash_os);
|
||||||
|
#endif
|
||||||
hash_os.resultAsString(str);
|
hash_os.resultAsString(str);
|
||||||
IF_LOG Logger::println("Module's LLVM bitcode hash is: %s", str.c_str());
|
IF_LOG Logger::println("Module's LLVM bitcode hash is: %s", str.c_str());
|
||||||
}
|
}
|
||||||
|
|
|
@ -354,6 +354,13 @@ void writeModule(llvm::Module *m, const char *filename) {
|
||||||
errinfo.message().c_str());
|
errinfo.message().c_str());
|
||||||
fatal();
|
fatal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if LDC_LLVM_VER >= 700
|
||||||
|
auto &M = *m;
|
||||||
|
#else
|
||||||
|
auto M = m;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (opts::isUsingThinLTO()) {
|
if (opts::isUsingThinLTO()) {
|
||||||
#if LDC_LLVM_VER >= 309
|
#if LDC_LLVM_VER >= 309
|
||||||
Logger::println("Creating module summary for ThinLTO");
|
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);
|
*m, /* function freq callback */ nullptr, &PSI);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
llvm::WriteBitcodeToFile(m, bos, true, &moduleSummaryIndex,
|
llvm::WriteBitcodeToFile(M, bos, true, &moduleSummaryIndex,
|
||||||
/* generate ThinLTO hash */ true);
|
/* generate ThinLTO hash */ true);
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
llvm::WriteBitcodeToFile(m, bos);
|
llvm::WriteBitcodeToFile(M, bos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -657,7 +657,11 @@ void setupModuleBitcodeData(const llvm::Module &srcModule, IRState *irs,
|
||||||
|
|
||||||
llvm::SmallString<1024> str;
|
llvm::SmallString<1024> str;
|
||||||
llvm::raw_svector_ostream os(str);
|
llvm::raw_svector_ostream os(str);
|
||||||
|
#if LDC_LLVM_VER >= 700
|
||||||
|
llvm::WriteBitcodeToFile(srcModule, os);
|
||||||
|
#else
|
||||||
llvm::WriteBitcodeToFile(&srcModule, os);
|
llvm::WriteBitcodeToFile(&srcModule, os);
|
||||||
|
#endif
|
||||||
|
|
||||||
auto runtimeCompiledIr = new llvm::GlobalVariable(
|
auto runtimeCompiledIr = new llvm::GlobalVariable(
|
||||||
irs->module, llvm::Type::getInt8PtrTy(irs->context()), true,
|
irs->module, llvm::Type::getInt8PtrTy(irs->context()), true,
|
||||||
|
@ -724,7 +728,12 @@ void generateBitcodeForDynamicCompile(IRState *irs) {
|
||||||
|
|
||||||
llvm::ValueToValueMapTy unused;
|
llvm::ValueToValueMapTy unused;
|
||||||
auto newModule = llvm::CloneModule(
|
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
|
// We don't dereference here, so const_cast should be safe
|
||||||
auto it = filter.find(const_cast<llvm::GlobalValue *>(val));
|
auto it = filter.find(const_cast<llvm::GlobalValue *>(val));
|
||||||
return filter.end() != it &&
|
return filter.end() != it &&
|
||||||
|
|
|
@ -188,10 +188,11 @@ public:
|
||||||
#if LDC_LLVM_VER >= 700
|
#if LDC_LLVM_VER >= 700
|
||||||
execSession(stringPool), resolver(createResolver()),
|
execSession(stringPool), resolver(createResolver()),
|
||||||
objectLayer(execSession,
|
objectLayer(execSession,
|
||||||
[](llvm::orc::VModuleKey) {
|
[this](llvm::orc::VModuleKey) {
|
||||||
return std::make_shared<llvm::SectionMemoryManager>();
|
return llvm::orc::RTDyldObjectLinkingLayer::Resources{
|
||||||
},
|
std::make_shared<llvm::SectionMemoryManager>(),
|
||||||
[this](llvm::orc::VModuleKey) { return resolver; }),
|
resolver};
|
||||||
|
}),
|
||||||
#else
|
#else
|
||||||
objectLayer(
|
objectLayer(
|
||||||
[]() { return std::make_shared<llvm::SectionMemoryManager>(); }),
|
[]() { return std::make_shared<llvm::SectionMemoryManager>(); }),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue