Skip to content

Commit 91eadcf

Browse files
committed
[Pipelines] Perform mergefunc after constmerge
Constmerge can fold switch jump tables, possibly making functions identical again. It can help mergefunc. On the otherhand, the opposite seems unlikely. Fixes #92201
1 parent 9f15aa0 commit 91eadcf

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

llvm/lib/Passes/PassBuilderPipelines.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1525,17 +1525,18 @@ PassBuilder::buildModuleOptimizationPipeline(OptimizationLevel Level,
15251525
if (EnableIROutliner)
15261526
MPM.addPass(IROutlinerPass());
15271527

1528-
// Merge functions if requested.
1529-
if (PTO.MergeFunctions)
1530-
MPM.addPass(MergeFunctionsPass());
1531-
15321528
// Now we need to do some global optimization transforms.
15331529
// FIXME: It would seem like these should come first in the optimization
15341530
// pipeline and maybe be the bottom of the canonicalization pipeline? Weird
15351531
// ordering here.
15361532
MPM.addPass(GlobalDCEPass());
15371533
MPM.addPass(ConstantMergePass());
15381534

1535+
// Merge functions if requested. It has a better chance to merge functions
1536+
// after ConstantMerge folded jump tables.
1537+
if (PTO.MergeFunctions)
1538+
MPM.addPass(MergeFunctionsPass());
1539+
15391540
if (PTO.CallGraphProfile && !LTOPreLink)
15401541
MPM.addPass(CGProfilePass(LTOPhase == ThinOrFullLTOPhase::FullLTOPostLink ||
15411542
LTOPhase == ThinOrFullLTOPhase::ThinLTOPostLink));

llvm/test/Other/new-pm-defaults.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,9 +280,9 @@
280280
; CHECK-HOT-COLD-SPLIT-NEXT: Running pass: HotColdSplittingPass
281281
; CHECK-IR-OUTLINER-NEXT: Running pass: IROutlinerPass
282282
; CHECK-IR-OUTLINER-NEXT: Running analysis: IRSimilarityAnalysis
283-
; CHECK-MERGE-FUNCS-NEXT: Running pass: MergeFunctionsPass
284283
; CHECK-O-NEXT: Running pass: GlobalDCEPass
285284
; CHECK-O-NEXT: Running pass: ConstantMergePass
285+
; CHECK-MERGE-FUNCS-NEXT: Running pass: MergeFunctionsPass
286286
; CHECK-DEFAULT-NEXT: Running pass: CGProfilePass
287287
; CHECK-DEFAULT-NEXT: Running pass: RelLookupTableConverterPass
288288
; CHECK-LTO-NOT: Running pass: RelLookupTableConverterPass

0 commit comments

Comments
 (0)