about summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2021-03-02 21:54:03 +0100
committerNikita Popov <nikita.ppv@gmail.com>2021-03-03 20:48:37 +0100
commit9a8acea78355b604dbeb29bc38bd4dbf7bfce95f (patch)
tree4c206ed81fe738fa704cdfe17206999d16ac84c9 /compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
parentea0aa8def379657559419a4dd2707e3bc60512b8 (diff)
downloadrust-9a8acea78355b604dbeb29bc38bd4dbf7bfce95f.tar.gz
rust-9a8acea78355b604dbeb29bc38bd4dbf7bfce95f.zip
Schedule ThinLTOBuffer passes again after sanitizer passes
This works around a design defect in the LLVM 12 pass builder
implementation. In LLVM 13, the PreLink ThinLTO pipeline properly
respects the OptimizerLastEPCallbacks.
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp')
-rw-r--r--compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
index 79babd27a30..2f28162f908 100644
--- a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
+++ b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
@@ -1015,7 +1015,12 @@ LLVMRustOptimizeWithNewPassManager(
       case LLVMRustOptStage::PreLinkThinLTO:
 #if LLVM_VERSION_GE(12, 0)
         MPM = PB.buildThinLTOPreLinkDefaultPipeline(OptLevel);
-        NeedThinLTOBufferPasses = false;
+        // The ThinLTOPreLink pipeline already includes ThinLTOBuffer passes. However, callback
+        // passes may still run afterwards. This means we need to run the buffer passes again.
+        // FIXME: In LLVM 13, the ThinLTOPreLink pipeline also runs OptimizerLastEPCallbacks
+        // before the RequiredLTOPreLinkPasses, in which case we can remove these hacks.
+        if (OptimizerLastEPCallbacks.empty())
+          NeedThinLTOBufferPasses = false;
 #else
         MPM = PB.buildThinLTOPreLinkDefaultPipeline(OptLevel, DebugPassManager);
 #endif