[PATCH] D112129: [FuncSpec] Enable it only with -O3
Sjoerd Meijer via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 20 03:52:37 PDT 2021
SjoerdMeijer created this revision.
SjoerdMeijer added reviewers: ChuanqiXu, snehasish, aeubanks, nikic.
Herald added subscribers: ormris, hiraditya.
SjoerdMeijer requested review of this revision.
Herald added a project: LLVM.
Looks like function specialisation was running at all optimisation levels (if enabled on the command line, it is not on by default). I think that was an oversight and not something we want to do. Function specialisation duplicates functions when it triggers, so the backend is processing more functions/instructions resulting in compile-time increases, which seems more appropriate with -O3 and inline with GCC.
Please note that since function specialisation is not enabled by default, this didn't require updating any pass manager tests.
https://reviews.llvm.org/D112129
Files:
llvm/lib/Passes/PassBuilderPipelines.cpp
llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
Index: llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
===================================================================
--- llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
+++ llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
@@ -1017,7 +1017,7 @@
createPGOIndirectCallPromotionLegacyPass(true, !PGOSampleUse.empty()));
// Propage constant function arguments by specializing the functions.
- if (EnableFunctionSpecialization)
+ if (EnableFunctionSpecialization && OptLevel > 2)
PM.add(createFunctionSpecializationPass());
// Propagate constants at call sites into the functions they call. This
Index: llvm/lib/Passes/PassBuilderPipelines.cpp
===================================================================
--- llvm/lib/Passes/PassBuilderPipelines.cpp
+++ llvm/lib/Passes/PassBuilderPipelines.cpp
@@ -832,7 +832,7 @@
C(MPM, Level);
// Specialize functions with IPSCCP.
- if (EnableFunctionSpecialization)
+ if (EnableFunctionSpecialization && Level == OptimizationLevel::O3)
MPM.addPass(FunctionSpecializationPass());
// Interprocedural constant propagation now that basic cleanup has occurred
@@ -1399,7 +1399,7 @@
MPM.addPass(PGOIndirectCallPromotion(
true /* InLTO */, PGOOpt && PGOOpt->Action == PGOOptions::SampleUse));
- if (EnableFunctionSpecialization)
+ if (EnableFunctionSpecialization && Level.getSpeedupLevel() > 2)
MPM.addPass(FunctionSpecializationPass());
// Propagate constants at call sites into the functions they call. This
// opens opportunities for globalopt (and inlining) by substituting function
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112129.380888.patch
Type: text/x-patch
Size: 1620 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211020/6d85637d/attachment.bin>
More information about the llvm-commits
mailing list