Skip to content

Commit 429ff8c

Browse files
authored
[NewPM] Add missing LTO ArgPromotion pass (#115)
This is a followup to D96780 to add one more pass missing from the NewPM LTO pipeline. The missing ArgPromotion run is inserted at the same position as in the LegacyPM, resolving the already present FIXME: https://github.com/llvm/llvm-project/blob/16086d47c0d0cd08ffae8e69a69c88653e654d01/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp#L1096-L1098 The compile-time impact is minimal with ~0.1% geomean regression on CTMark. Differential Revision: https://reviews.llvm.org/D108866 (cherry picked from commit b28c3b9)
1 parent a04279d commit 429ff8c

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

llvm/lib/Passes/PassBuilder.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1784,9 +1784,12 @@ PassBuilder::buildLTODefaultPipeline(OptimizationLevel Level,
17841784
MPM.addPass(GlobalOptPass());
17851785

17861786
// Garbage collect dead functions.
1787-
// FIXME: Add ArgumentPromotion pass after once it's ported.
17881787
MPM.addPass(GlobalDCEPass());
17891788

1789+
// If we didn't decide to inline a function, check to see if we can
1790+
// transform it to pass arguments by value instead of by reference.
1791+
MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(ArgumentPromotionPass()));
1792+
17901793
FunctionPassManager FPM;
17911794
// The IPO Passes may leave cruft around. Clean up after them.
17921795
FPM.addPass(InstCombinePass());

llvm/test/Other/new-pm-lto-defaults.ll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
; CHECK-O23SZ-NEXT: Running pass: InlinerPass
7474
; CHECK-O23SZ-NEXT: Running pass: GlobalOptPass
7575
; CHECK-O23SZ-NEXT: Running pass: GlobalDCEPass
76+
; CHECK-O23SZ-NEXT: Running pass: ArgumentPromotionPass
7677
; CHECK-O23SZ-NEXT: Running pass: InstCombinePass
7778
; CHECK-EP-Peephole-NEXT: Running pass: NoOpFunctionPass
7879
; CHECK-O23SZ-NEXT: Running pass: JumpThreadingPass

0 commit comments

Comments
 (0)