[llvm] fb56834 - [Pipelines] Restore old DAE position in LTO pipeline

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 14 09:00:25 PDT 2023


Author: Nikita Popov
Date: 2023-03-14T17:00:17+01:00
New Revision: fb5683449e97bd8c2d107128dcf08d6f93789315

URL: https://github.com/llvm/llvm-project/commit/fb5683449e97bd8c2d107128dcf08d6f93789315
DIFF: https://github.com/llvm/llvm-project/commit/fb5683449e97bd8c2d107128dcf08d6f93789315.diff

LOG: [Pipelines] Restore old DAE position in LTO pipeline

This is a partial revert of D128830, restoring the previous
position of DeadArgElim in the fat LTO pipeline. The motivation
for this is a major code size regression observed in Rust and
illustrated in the PhaseOrdering test.

This is a conservative fix restoring the previous pipeline order.
The real problem is that the LTO pipeline is conceptually broken:
It doesn't have a CGSCC function simplification pipeline. The
inliner is just being run by itself. This wouldn't be a problem
if fat LTO used a standard design where ArgPromotion and DAE are
only run after functions have already been simplified by the
CGSCC inliner pipeline.

Differential Revision: https://reviews.llvm.org/D146051

Added: 
    

Modified: 
    llvm/lib/Passes/PassBuilderPipelines.cpp
    llvm/test/Other/new-pm-lto-defaults.ll
    llvm/test/Transforms/PhaseOrdering/dae-dce.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Passes/PassBuilderPipelines.cpp b/llvm/lib/Passes/PassBuilderPipelines.cpp
index 4021ece4990d7..9efc16186c8f8 100644
--- a/llvm/lib/Passes/PassBuilderPipelines.cpp
+++ b/llvm/lib/Passes/PassBuilderPipelines.cpp
@@ -1688,6 +1688,9 @@ PassBuilder::buildLTODefaultPipeline(OptimizationLevel Level,
   // keep one copy of each constant.
   MPM.addPass(ConstantMergePass());
 
+  // Remove unused arguments from functions.
+  MPM.addPass(DeadArgumentEliminationPass());
+
   // Reduce the code after globalopt and ipsccp.  Both can open up significant
   // simplification opportunities, and both can propagate functions through
   // function pointers.  When this happens, we often have to resolve varargs
@@ -1725,9 +1728,6 @@ PassBuilder::buildLTODefaultPipeline(OptimizationLevel Level,
   // transform it to pass arguments by value instead of by reference.
   MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(ArgumentPromotionPass()));
 
-  // Remove unused arguments from functions.
-  MPM.addPass(DeadArgumentEliminationPass());
-
   FunctionPassManager FPM;
   // The IPO Passes may leave cruft around. Clean up after them.
   FPM.addPass(InstCombinePass());

diff  --git a/llvm/test/Other/new-pm-lto-defaults.ll b/llvm/test/Other/new-pm-lto-defaults.ll
index f93a39b9578c1..c9171e3734e0b 100644
--- a/llvm/test/Other/new-pm-lto-defaults.ll
+++ b/llvm/test/Other/new-pm-lto-defaults.ll
@@ -68,6 +68,7 @@
 ; CHECK-O23SZ-NEXT: Running pass: GlobalOptPass
 ; CHECK-O23SZ-NEXT: Running pass: PromotePass
 ; CHECK-O23SZ-NEXT: Running pass: ConstantMergePass
+; CHECK-O23SZ-NEXT: Running pass: DeadArgumentEliminationPass
 ; CHECK-O23SZ-NEXT: Running pass: InstCombinePass
 ; CHECK-O3-NEXT: Running pass: AggressiveInstCombinePass
 ; CHECK-EP-Peephole-NEXT: Running pass: NoOpFunctionPass
@@ -80,7 +81,6 @@
 ; CHECK-O23SZ-NEXT: Running pass: OpenMPOptPass
 ; CHECK-O23SZ-NEXT: Running pass: GlobalDCEPass
 ; CHECK-O23SZ-NEXT: Running pass: ArgumentPromotionPass
-; CHECK-O23SZ-NEXT: Running pass: DeadArgumentEliminationPass
 ; CHECK-O23SZ-NEXT: Running pass: InstCombinePass
 ; CHECK-EP-Peephole-NEXT: Running pass: NoOpFunctionPass
 ; CHECK-O23SZ-NEXT: Running pass: ConstraintEliminationPass

diff  --git a/llvm/test/Transforms/PhaseOrdering/dae-dce.ll b/llvm/test/Transforms/PhaseOrdering/dae-dce.ll
index 8a0a36ef6cff9..7ff3c5dc5536f 100644
--- a/llvm/test/Transforms/PhaseOrdering/dae-dce.ll
+++ b/llvm/test/Transforms/PhaseOrdering/dae-dce.ll
@@ -25,32 +25,17 @@ define internal void @capture_and_trap(ptr %ptr) noinline {
 }
 
 define internal void @dead_fn1() {
-; LTO-LABEL: @dead_fn1(
-; LTO-NEXT:    ret void
-;
   ret void
 }
 
 define internal void @dead_fn2() {
-; LTO-LABEL: @dead_fn2(
-; LTO-NEXT:    ret void
-;
   ret void
 }
 
 define void @test(i1 %c) {
-; DEFAULT-LABEL: @test(
-; DEFAULT-NEXT:    tail call fastcc void @capture_and_trap()
-; DEFAULT-NEXT:    unreachable
-;
-; LTO-LABEL: @test(
-; LTO-NEXT:    br i1 [[C:%.*]], label [[IF:%.*]], label [[ELSE:%.*]]
-; LTO:       if:
-; LTO-NEXT:    tail call fastcc void @capture_and_trap(ptr nonnull @dead_fn1)
-; LTO-NEXT:    unreachable
-; LTO:       else:
-; LTO-NEXT:    tail call fastcc void @capture_and_trap(ptr nonnull @dead_fn2)
-; LTO-NEXT:    unreachable
+; CHECK-LABEL: @test(
+; CHECK-NEXT:    tail call fastcc void @capture_and_trap()
+; CHECK-NEXT:    unreachable
 ;
   br i1 %c, label %if, label %else
 
@@ -62,3 +47,6 @@ else:
   call void @capture_and_trap(ptr @dead_fn2)
   unreachable
 }
+;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
+; DEFAULT: {{.*}}
+; LTO: {{.*}}


        


More information about the llvm-commits mailing list