Skip to content

Commit b28c3b9

Browse files
committed
[NewPM] Add missing LTO ArgPromotion pass
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
1 parent 4948927 commit b28c3b9

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
@@ -1783,9 +1783,12 @@ PassBuilder::buildLTODefaultPipeline(OptimizationLevel Level,
17831783
MPM.addPass(GlobalOptPass());
17841784

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

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