llvm-wrapper: adapt for LLVM API changes

No functional changes intended.

Adapts PassWrapper for two recent LLVM API changes:
* e7bac3b9fa
* 93600eb50c
* 5e38b2a456
This commit is contained in:
Krasimir Georgiev 2022-09-07 12:08:06 +00:00
parent 0568b0a3de
commit a3b60f1769

View File

@ -936,12 +936,14 @@ LLVMRustOptimizeWithNewPassManager(
/*CompileKernel=*/false);
OptimizerLastEPCallbacks.push_back(
[Options](ModulePassManager &MPM, OptimizationLevel Level) {
#if LLVM_VERSION_GE(14, 0)
#if LLVM_VERSION_GE(14, 0) && LLVM_VERSION_LT(16, 0)
MPM.addPass(ModuleMemorySanitizerPass(Options));
#else
MPM.addPass(MemorySanitizerPass(Options));
#endif
#if LLVM_VERSION_LT(16, 0)
MPM.addPass(createModuleToFunctionPassAdaptor(MemorySanitizerPass(Options)));
#endif
}
);
}
@ -972,7 +974,11 @@ LLVMRustOptimizeWithNewPassManager(
/*UseAfterScope=*/true,
AsanDetectStackUseAfterReturnMode::Runtime,
};
#if LLVM_VERSION_LT(16, 0)
MPM.addPass(ModuleAddressSanitizerPass(opts));
#else
MPM.addPass(AddressSanitizerPass(opts));
#endif
#else
MPM.addPass(ModuleAddressSanitizerPass(
/*CompileKernel=*/false, SanitizerOptions->SanitizeAddressRecover));