Skip to content

Commit

Permalink
Schedule ThinLTOBuffer passes again after sanitizer passes
Browse files Browse the repository at this point in the history
This works around a design defect in the LLVM 12 pass builder
implementation. In LLVM 13, the PreLink ThinLTO pipeline properly
respects the OptimizerLastEPCallbacks.
  • Loading branch information
nikic committed Mar 3, 2021
1 parent ea0aa8d commit 9a8acea
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9a8acea

Please sign in to comment.