From 6234a5694936cb0f7c9a3fb456ae4c0aeee69f11 Mon Sep 17 00:00:00 2001 From: Augie Fackler Date: Thu, 4 Nov 2021 17:16:16 -0400 Subject: [PATCH 1/3] rustc_llvm: update PassWrapper for recent LLVM Now AddressSanitizerOptions is a struct, but at least the change was tiny. r? nikic --- compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp index ddbc3c5912836..94dce9f46fbc1 100644 --- a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp @@ -889,15 +889,18 @@ LLVMRustOptimizeWithNewPassManager( OptimizerLastEPCallbacks.push_back( [SanitizerOptions](ModulePassManager &MPM, OptimizationLevel Level) { MPM.addPass(RequireAnalysisPass()); - MPM.addPass(ModuleAddressSanitizerPass( - /*CompileKernel=*/false, SanitizerOptions->SanitizeAddressRecover)); #if LLVM_VERSION_GE(14, 0) - AddressSanitizerOptions opts(/*CompileKernel=*/false, - SanitizerOptions->SanitizeAddressRecover, - /*UseAfterScope=*/true, - AsanDetectStackUseAfterReturnMode::Runtime); + AddressSanitizerOptions opts = AddressSanitizerOptions{ + /*CompileKernel=*/false, + SanitizerOptions->SanitizeAddressRecover, + /*UseAfterScope=*/false, + AsanDetectStackUseAfterReturnMode::Runtime, + }; + MPM.addPass(ModuleAddressSanitizerPass(opts)); MPM.addPass(createModuleToFunctionPassAdaptor(AddressSanitizerPass(opts))); #else + MPM.addPass(ModuleAddressSanitizerPass( + /*CompileKernel=*/false, SanitizerOptions->SanitizeAddressRecover)); MPM.addPass(createModuleToFunctionPassAdaptor(AddressSanitizerPass( /*CompileKernel=*/false, SanitizerOptions->SanitizeAddressRecover, /*UseAfterScope=*/true))); From d440ce6a9f6d8cfa532007add77754d956038407 Mon Sep 17 00:00:00 2001 From: Augie Fackler Date: Thu, 4 Nov 2021 18:08:32 -0400 Subject: [PATCH 2/3] Didn't mean to invert this boolean. --- compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp index 94dce9f46fbc1..baeb17ed1cb6d 100644 --- a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp @@ -893,7 +893,7 @@ LLVMRustOptimizeWithNewPassManager( AddressSanitizerOptions opts = AddressSanitizerOptions{ /*CompileKernel=*/false, SanitizerOptions->SanitizeAddressRecover, - /*UseAfterScope=*/false, + /*UseAfterScope=*/true, AsanDetectStackUseAfterReturnMode::Runtime, }; MPM.addPass(ModuleAddressSanitizerPass(opts)); From d9f2d5f0e9c55f440d043c3614b164d7c9fa70ce Mon Sep 17 00:00:00 2001 From: Krasimir Georgiev Date: Thu, 11 Nov 2021 09:03:23 -0500 Subject: [PATCH 3/3] PassWrapper: additional sanitizer update to match clang This happened later in the stream than the other changes, but the fix is overlapping. Fix taken from a55c4ec1cee7683d9095327d9d33e7137ec25292 in LLVM. --- compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp index baeb17ed1cb6d..4f77db8a24dc4 100644 --- a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp @@ -897,7 +897,6 @@ LLVMRustOptimizeWithNewPassManager( AsanDetectStackUseAfterReturnMode::Runtime, }; MPM.addPass(ModuleAddressSanitizerPass(opts)); - MPM.addPass(createModuleToFunctionPassAdaptor(AddressSanitizerPass(opts))); #else MPM.addPass(ModuleAddressSanitizerPass( /*CompileKernel=*/false, SanitizerOptions->SanitizeAddressRecover));