Merge remote-tracking branch 'origin/master' into merge-2.104

This commit is contained in:
Martin Kinkelin 2023-07-23 22:50:27 +02:00
commit b97ae0340d
23 changed files with 606 additions and 55 deletions

View file

@ -393,8 +393,27 @@ void registerModuleInfo(Module *m) {
emitModuleRefToSection(mangle, moduleInfoSym);
}
}
void addModuleFlags(llvm::Module &m) {
#if LDC_LLVM_VER >= 1500
const auto ModuleMinFlag = llvm::Module::Min;
#else
const auto ModuleMinFlag = llvm::Module::Warning; // Fallback value
#endif
if (opts::fCFProtection == opts::CFProtectionType::Return ||
opts::fCFProtection == opts::CFProtectionType::Full) {
m.addModuleFlag(ModuleMinFlag, "cf-protection-return", 1);
}
if (opts::fCFProtection == opts::CFProtectionType::Branch ||
opts::fCFProtection == opts::CFProtectionType::Full) {
m.addModuleFlag(ModuleMinFlag, "cf-protection-branch", 1);
}
}
} // anonymous namespace
void codegenModule(IRState *irs, Module *m) {
TimeTraceScope timeScope("Generate IR", m->toChars(), m->loc);
@ -446,6 +465,8 @@ void codegenModule(IRState *irs, Module *m) {
addCoverageAnalysisInitializer(m);
}
addModuleFlags(irs->module);
gIR = nullptr;
irs->dmodule = nullptr;
}