[PATCH] D108866: [NewPM] Add missing LTO ArgPromotion pass

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 28 04:09:33 PDT 2021


nikic created this revision.
nikic added reviewers: dmgreen, fhahn, aeubanks.
Herald added subscribers: ormris, steven_wu, JDevlieghere, hiraditya, inglorion.
nikic requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This is a followup to D96780 <https://reviews.llvm.org/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 (https://github.com/llvm/llvm-project/blob/16086d47c0d0cd08ffae8e69a69c88653e654d01/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp#L1096-L1098), which resolves the already present TODO.

The compile-time impact is minimal: https://llvm-compile-time-tracker.com/compare.php?from=16086d47c0d0cd08ffae8e69a69c88653e654d01&to=90de51b3dfb00239941f00b0eeaa7fc78db2f8b8&stat=instructions

I believe this resolves the last blocker for the NewPM migration in rustc...


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108866

Files:
  llvm/lib/Passes/PassBuilder.cpp
  llvm/test/Other/new-pm-lto-defaults.ll


Index: llvm/test/Other/new-pm-lto-defaults.ll
===================================================================
--- llvm/test/Other/new-pm-lto-defaults.ll
+++ llvm/test/Other/new-pm-lto-defaults.ll
@@ -73,6 +73,7 @@
 ; CHECK-O23SZ-NEXT: Running pass: InlinerPass
 ; CHECK-O23SZ-NEXT: Running pass: GlobalOptPass
 ; CHECK-O23SZ-NEXT: Running pass: GlobalDCEPass
+; CHECK-O23SZ-NEXT: Running pass: ArgumentPromotionPass
 ; CHECK-O23SZ-NEXT: Running pass: InstCombinePass
 ; CHECK-EP-Peephole-NEXT: Running pass: NoOpFunctionPass
 ; CHECK-O23SZ-NEXT: Running pass: JumpThreadingPass
Index: llvm/lib/Passes/PassBuilder.cpp
===================================================================
--- llvm/lib/Passes/PassBuilder.cpp
+++ llvm/lib/Passes/PassBuilder.cpp
@@ -1783,9 +1783,12 @@
   MPM.addPass(GlobalOptPass());
 
   // Garbage collect dead functions.
-  // FIXME: Add ArgumentPromotion pass after once it's ported.
   MPM.addPass(GlobalDCEPass());
 
+  // If we didn't decide to inline a function, check to see if we can
+  // transform it to pass arguments by value instead of by reference.
+  MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(ArgumentPromotionPass()));
+
   FunctionPassManager FPM;
   // The IPO Passes may leave cruft around. Clean up after them.
   FPM.addPass(InstCombinePass());


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108866.369250.patch
Type: text/x-patch
Size: 1311 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210828/e13e7650/attachment.bin>


More information about the llvm-commits mailing list