Stub out various legacy PM functions with LLVM 15
This commit is contained in:
parent
7dc307fc7a
commit
890cabac8a
3 changed files with 46 additions and 2 deletions
|
@ -625,7 +625,7 @@ pub(crate) fn run_pass_manager(
|
||||||
if thin {
|
if thin {
|
||||||
llvm::LLVMRustPassManagerBuilderPopulateThinLTOPassManager(b, pm);
|
llvm::LLVMRustPassManagerBuilderPopulateThinLTOPassManager(b, pm);
|
||||||
} else {
|
} else {
|
||||||
llvm::LLVMPassManagerBuilderPopulateLTOPassManager(
|
llvm::LLVMRustPassManagerBuilderPopulateLTOPassManager(
|
||||||
b, pm, /* Internalize = */ False, /* RunInliner = */ True,
|
b, pm, /* Internalize = */ False, /* RunInliner = */ True,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1842,7 +1842,7 @@ extern "C" {
|
||||||
PMB: &PassManagerBuilder,
|
PMB: &PassManagerBuilder,
|
||||||
PM: &PassManager<'_>,
|
PM: &PassManager<'_>,
|
||||||
);
|
);
|
||||||
pub fn LLVMPassManagerBuilderPopulateLTOPassManager(
|
pub fn LLVMRustPassManagerBuilderPopulateLTOPassManager(
|
||||||
PMB: &PassManagerBuilder,
|
PMB: &PassManagerBuilder,
|
||||||
PM: &PassManager<'_>,
|
PM: &PassManager<'_>,
|
||||||
Internalize: Bool,
|
Internalize: Bool,
|
||||||
|
|
|
@ -107,6 +107,7 @@ static LLVMRustPassKind toRust(PassKind Kind) {
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" LLVMPassRef LLVMRustFindAndCreatePass(const char *PassName) {
|
extern "C" LLVMPassRef LLVMRustFindAndCreatePass(const char *PassName) {
|
||||||
|
#if LLVM_VERSION_LT(15, 0)
|
||||||
StringRef SR(PassName);
|
StringRef SR(PassName);
|
||||||
PassRegistry *PR = PassRegistry::getPassRegistry();
|
PassRegistry *PR = PassRegistry::getPassRegistry();
|
||||||
|
|
||||||
|
@ -115,36 +116,59 @@ extern "C" LLVMPassRef LLVMRustFindAndCreatePass(const char *PassName) {
|
||||||
return wrap(PI->createPass());
|
return wrap(PI->createPass());
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
#else
|
||||||
|
report_fatal_error("Legacy PM not supported with LLVM 15");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" LLVMPassRef LLVMRustCreateAddressSanitizerFunctionPass(bool Recover) {
|
extern "C" LLVMPassRef LLVMRustCreateAddressSanitizerFunctionPass(bool Recover) {
|
||||||
|
#if LLVM_VERSION_LT(15, 0)
|
||||||
const bool CompileKernel = false;
|
const bool CompileKernel = false;
|
||||||
const bool UseAfterScope = true;
|
const bool UseAfterScope = true;
|
||||||
|
|
||||||
return wrap(createAddressSanitizerFunctionPass(CompileKernel, Recover, UseAfterScope));
|
return wrap(createAddressSanitizerFunctionPass(CompileKernel, Recover, UseAfterScope));
|
||||||
|
#else
|
||||||
|
report_fatal_error("Legacy PM not supported with LLVM 15");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" LLVMPassRef LLVMRustCreateModuleAddressSanitizerPass(bool Recover) {
|
extern "C" LLVMPassRef LLVMRustCreateModuleAddressSanitizerPass(bool Recover) {
|
||||||
|
#if LLVM_VERSION_LT(15, 0)
|
||||||
const bool CompileKernel = false;
|
const bool CompileKernel = false;
|
||||||
|
|
||||||
return wrap(createModuleAddressSanitizerLegacyPassPass(CompileKernel, Recover));
|
return wrap(createModuleAddressSanitizerLegacyPassPass(CompileKernel, Recover));
|
||||||
|
#else
|
||||||
|
report_fatal_error("Legacy PM not supported with LLVM 15");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" LLVMPassRef LLVMRustCreateMemorySanitizerPass(int TrackOrigins, bool Recover) {
|
extern "C" LLVMPassRef LLVMRustCreateMemorySanitizerPass(int TrackOrigins, bool Recover) {
|
||||||
|
#if LLVM_VERSION_LT(15, 0)
|
||||||
const bool CompileKernel = false;
|
const bool CompileKernel = false;
|
||||||
|
|
||||||
return wrap(createMemorySanitizerLegacyPassPass(
|
return wrap(createMemorySanitizerLegacyPassPass(
|
||||||
MemorySanitizerOptions{TrackOrigins, Recover, CompileKernel}));
|
MemorySanitizerOptions{TrackOrigins, Recover, CompileKernel}));
|
||||||
|
#else
|
||||||
|
report_fatal_error("Legacy PM not supported with LLVM 15");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" LLVMPassRef LLVMRustCreateThreadSanitizerPass() {
|
extern "C" LLVMPassRef LLVMRustCreateThreadSanitizerPass() {
|
||||||
|
#if LLVM_VERSION_LT(15, 0)
|
||||||
return wrap(createThreadSanitizerLegacyPassPass());
|
return wrap(createThreadSanitizerLegacyPassPass());
|
||||||
|
#else
|
||||||
|
report_fatal_error("Legacy PM not supported with LLVM 15");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" LLVMPassRef LLVMRustCreateHWAddressSanitizerPass(bool Recover) {
|
extern "C" LLVMPassRef LLVMRustCreateHWAddressSanitizerPass(bool Recover) {
|
||||||
|
#if LLVM_VERSION_LT(15, 0)
|
||||||
const bool CompileKernel = false;
|
const bool CompileKernel = false;
|
||||||
|
|
||||||
return wrap(createHWAddressSanitizerLegacyPassPass(CompileKernel, Recover));
|
return wrap(createHWAddressSanitizerLegacyPassPass(CompileKernel, Recover));
|
||||||
|
#else
|
||||||
|
report_fatal_error("Legacy PM not supported with LLVM 15");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" LLVMRustPassKind LLVMRustPassKind(LLVMPassRef RustPass) {
|
extern "C" LLVMRustPassKind LLVMRustPassKind(LLVMPassRef RustPass) {
|
||||||
|
@ -154,10 +178,22 @@ extern "C" LLVMRustPassKind LLVMRustPassKind(LLVMPassRef RustPass) {
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void LLVMRustAddPass(LLVMPassManagerRef PMR, LLVMPassRef RustPass) {
|
extern "C" void LLVMRustAddPass(LLVMPassManagerRef PMR, LLVMPassRef RustPass) {
|
||||||
|
#if LLVM_VERSION_LT(15, 0)
|
||||||
assert(RustPass);
|
assert(RustPass);
|
||||||
Pass *Pass = unwrap(RustPass);
|
Pass *Pass = unwrap(RustPass);
|
||||||
PassManagerBase *PMB = unwrap(PMR);
|
PassManagerBase *PMB = unwrap(PMR);
|
||||||
PMB->add(Pass);
|
PMB->add(Pass);
|
||||||
|
#else
|
||||||
|
report_fatal_error("Legacy PM not supported with LLVM 15");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
extern "C" void LLVMRustPassManagerBuilderPopulateLTOPassManager(
|
||||||
|
LLVMPassManagerBuilderRef PMB, LLVMPassManagerRef PM, bool Internalize, bool RunInliner) {
|
||||||
|
#if LLVM_VERSION_LT(15, 0)
|
||||||
|
LLVMPassManagerBuilderPopulateLTOPassManager(PMB, PM, Internalize, RunInliner);
|
||||||
|
#else
|
||||||
|
report_fatal_error("Legacy PM not supported with LLVM 15");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
|
@ -165,12 +201,17 @@ void LLVMRustPassManagerBuilderPopulateThinLTOPassManager(
|
||||||
LLVMPassManagerBuilderRef PMBR,
|
LLVMPassManagerBuilderRef PMBR,
|
||||||
LLVMPassManagerRef PMR
|
LLVMPassManagerRef PMR
|
||||||
) {
|
) {
|
||||||
|
#if LLVM_VERSION_LT(15, 0)
|
||||||
unwrap(PMBR)->populateThinLTOPassManager(*unwrap(PMR));
|
unwrap(PMBR)->populateThinLTOPassManager(*unwrap(PMR));
|
||||||
|
#else
|
||||||
|
report_fatal_error("Legacy PM not supported with LLVM 15");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
void LLVMRustAddLastExtensionPasses(
|
void LLVMRustAddLastExtensionPasses(
|
||||||
LLVMPassManagerBuilderRef PMBR, LLVMPassRef *Passes, size_t NumPasses) {
|
LLVMPassManagerBuilderRef PMBR, LLVMPassRef *Passes, size_t NumPasses) {
|
||||||
|
#if LLVM_VERSION_LT(15, 0)
|
||||||
auto AddExtensionPasses = [Passes, NumPasses](
|
auto AddExtensionPasses = [Passes, NumPasses](
|
||||||
const PassManagerBuilder &Builder, PassManagerBase &PM) {
|
const PassManagerBuilder &Builder, PassManagerBase &PM) {
|
||||||
for (size_t I = 0; I < NumPasses; I++) {
|
for (size_t I = 0; I < NumPasses; I++) {
|
||||||
|
@ -183,6 +224,9 @@ void LLVMRustAddLastExtensionPasses(
|
||||||
AddExtensionPasses);
|
AddExtensionPasses);
|
||||||
unwrap(PMBR)->addExtension(PassManagerBuilder::EP_EnabledOnOptLevel0,
|
unwrap(PMBR)->addExtension(PassManagerBuilder::EP_EnabledOnOptLevel0,
|
||||||
AddExtensionPasses);
|
AddExtensionPasses);
|
||||||
|
#else
|
||||||
|
report_fatal_error("Legacy PM not supported with LLVM 15");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LLVM_COMPONENT_X86
|
#ifdef LLVM_COMPONENT_X86
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue