Skip to content

Commit 9a8acea

Browse files
committedMar 3, 2021
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.
1 parent ea0aa8d commit 9a8acea

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed
 

‎compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,12 @@ LLVMRustOptimizeWithNewPassManager(
10151015
case LLVMRustOptStage::PreLinkThinLTO:
10161016
#if LLVM_VERSION_GE(12, 0)
10171017
MPM = PB.buildThinLTOPreLinkDefaultPipeline(OptLevel);
1018-
NeedThinLTOBufferPasses = false;
1018+
// The ThinLTOPreLink pipeline already includes ThinLTOBuffer passes. However, callback
1019+
// passes may still run afterwards. This means we need to run the buffer passes again.
1020+
// FIXME: In LLVM 13, the ThinLTOPreLink pipeline also runs OptimizerLastEPCallbacks
1021+
// before the RequiredLTOPreLinkPasses, in which case we can remove these hacks.
1022+
if (OptimizerLastEPCallbacks.empty())
1023+
NeedThinLTOBufferPasses = false;
10191024
#else
10201025
MPM = PB.buildThinLTOPreLinkDefaultPipeline(OptLevel, DebugPassManager);
10211026
#endif

0 commit comments

Comments
 (0)