[llvm-branch-commits] [llvm] b3ea348 - [Pipelines] Restore old DAE position in LTO pipeline

Tobias Hieta via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Mar 23 07:34:55 PDT 2023


Author: Nikita Popov
Date: 2023-03-23T15:32:38+01:00
New Revision: b3ea3484c063af2ec05c1d90cb21409884cb4fb6

URL: https://github.com/llvm/llvm-project/commit/b3ea3484c063af2ec05c1d90cb21409884cb4fb6
DIFF: https://github.com/llvm/llvm-project/commit/b3ea3484c063af2ec05c1d90cb21409884cb4fb6.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

(cherry picked from commit fb5683449e97bd8c2d107128dcf08d6f93789315)

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 eed29c25714b0..0d074951cffc5 100644
--- a/llvm/lib/Passes/PassBuilderPipelines.cpp
+++ b/llvm/lib/Passes/PassBuilderPipelines.cpp
@@ -1685,6 +1685,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
@@ -1722,9 +1725,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 55b4ad0526a0a..54ddfdf1cd98e 100644
--- a/llvm/test/Other/new-pm-lto-defaults.ll
+++ b/llvm/test/Other/new-pm-lto-defaults.ll
@@ -69,6 +69,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
@@ -81,7 +82,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: JumpThreadingPass

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-branch-commits mailing list