Skip to content

Commit ebc89c7

Browse files
committed
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 ebc89c7

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
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));

0 commit comments

Comments
 (0)