Index: llvm/lib/Passes/PassBuilderPipelines.cpp =================================================================== --- llvm/lib/Passes/PassBuilderPipelines.cpp +++ llvm/lib/Passes/PassBuilderPipelines.cpp @@ -1688,6 +1688,9 @@ // 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 @@ // 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()); 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 @@ -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 Index: llvm/test/Transforms/PhaseOrdering/dae-dce.ll =================================================================== --- llvm/test/Transforms/PhaseOrdering/dae-dce.ll +++ llvm/test/Transforms/PhaseOrdering/dae-dce.ll @@ -25,32 +25,17 @@ } 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 @@ 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: {{.*}}