Skip to content

Commit c4e6185

Browse files
committed
PassWrapper: adapt for LLVM 14 changes
These API changes appear to have all taken place in https://reviews.llvm.org/D105007, which moved HWAddressSanitizerPass and AddressSanitizerPass to only accept their options type as a ctor argument instead of the sequence of bools etc. This required a couple of parameter additions, which I made match the default prior to the mentioned upstream LLVM change. This patch restores rustc to building (though not quite passing all tests, I've mailed other patches for those issues) against LLVM HEAD.
1 parent a9ab2e5 commit c4e6185

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Diff for: compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -922,9 +922,17 @@ LLVMRustOptimizeWithNewPassManager(
922922
MPM.addPass(RequireAnalysisPass<ASanGlobalsMetadataAnalysis, Module>());
923923
MPM.addPass(ModuleAddressSanitizerPass(
924924
/*CompileKernel=*/false, SanitizerOptions->SanitizeAddressRecover));
925+
#if LLVM_VERSION_GE(14, 0)
926+
AddressSanitizerOptions opts(/*CompileKernel=*/false,
927+
SanitizerOptions->SanitizeAddressRecover,
928+
/*UseAfterScope=*/true,
929+
AsanDetectStackUseAfterReturnMode::Runtime);
930+
MPM.addPass(createModuleToFunctionPassAdaptor(AddressSanitizerPass(opts)));
931+
#else
925932
MPM.addPass(createModuleToFunctionPassAdaptor(AddressSanitizerPass(
926933
/*CompileKernel=*/false, SanitizerOptions->SanitizeAddressRecover,
927934
/*UseAfterScope=*/true)));
935+
#endif
928936
}
929937
);
930938
#else
@@ -952,8 +960,15 @@ LLVMRustOptimizeWithNewPassManager(
952960
#if LLVM_VERSION_GE(11, 0)
953961
OptimizerLastEPCallbacks.push_back(
954962
[SanitizerOptions](ModulePassManager &MPM, OptimizationLevel Level) {
963+
#if LLVM_VERSION_GE(14, 0)
964+
HWAddressSanitizerOptions opts(
965+
/*CompileKernel=*/false, SanitizerOptions->SanitizeHWAddressRecover,
966+
/*DisableOptimization=*/false);
967+
MPM.addPass(HWAddressSanitizerPass(opts));
968+
#else
955969
MPM.addPass(HWAddressSanitizerPass(
956970
/*CompileKernel=*/false, SanitizerOptions->SanitizeHWAddressRecover));
971+
#endif
957972
}
958973
);
959974
#else

0 commit comments

Comments
 (0)