From a97f89aeb4b4d7e2131f34c067df0f952fb8caad Mon Sep 17 00:00:00 2001 From: Augie Fackler Date: Thu, 16 Sep 2021 11:45:38 -0400 Subject: [PATCH 1/2] PassWrapper: handle separate Module*SanitizerPass Change ab41eef9aca3 in LLVM split MemorySanitizerPass into MemorySanitizerPass for functions and ModuleMemorySanitizerPass for modules. There's a related change for ThreadSanitizerPass, and in here since we're using a ModulePassManager I only add the module flavor of the pass on LLVM 14. r? @nikic cc @nagisa --- compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp index b3f86f3295ae9..3af1d31816e7e 100644 --- a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp @@ -875,8 +875,12 @@ LLVMRustOptimizeWithNewPassManager( #if LLVM_VERSION_GE(11, 0) OptimizerLastEPCallbacks.push_back( [Options](ModulePassManager &MPM, OptimizationLevel Level) { +#if LLVM_VERSION_GE(14, 0) + MPM.addPass(ModuleMemorySanitizerPass(Options)); +#else MPM.addPass(MemorySanitizerPass(Options)); MPM.addPass(createModuleToFunctionPassAdaptor(MemorySanitizerPass(Options))); +#endif } ); #else @@ -897,8 +901,12 @@ LLVMRustOptimizeWithNewPassManager( #if LLVM_VERSION_GE(11, 0) OptimizerLastEPCallbacks.push_back( [](ModulePassManager &MPM, OptimizationLevel Level) { +#if LLVM_VERSION_GE(14, 0) + MPM.addPass(ModuleThreadSanitizerPass()); +#else MPM.addPass(ThreadSanitizerPass()); MPM.addPass(createModuleToFunctionPassAdaptor(ThreadSanitizerPass())); +#endif } ); #else From bc4d8af123ce376261b1abd7acbc7d67a0197280 Mon Sep 17 00:00:00 2001 From: Augie Fackler Date: Thu, 16 Sep 2021 15:04:18 -0400 Subject: [PATCH 2/2] PassWrapper: these two lines shouldn't have been ifdef'd --- compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp index 3af1d31816e7e..b7cad1c3ba6d9 100644 --- a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp @@ -879,8 +879,8 @@ LLVMRustOptimizeWithNewPassManager( MPM.addPass(ModuleMemorySanitizerPass(Options)); #else MPM.addPass(MemorySanitizerPass(Options)); - MPM.addPass(createModuleToFunctionPassAdaptor(MemorySanitizerPass(Options))); #endif + MPM.addPass(createModuleToFunctionPassAdaptor(MemorySanitizerPass(Options))); } ); #else @@ -905,8 +905,8 @@ LLVMRustOptimizeWithNewPassManager( MPM.addPass(ModuleThreadSanitizerPass()); #else MPM.addPass(ThreadSanitizerPass()); - MPM.addPass(createModuleToFunctionPassAdaptor(ThreadSanitizerPass())); #endif + MPM.addPass(createModuleToFunctionPassAdaptor(ThreadSanitizerPass())); } ); #else