aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
diff options
context:
space:
mode:
authorHari Limaye <hari.limaye@arm.com>2024-10-29 11:41:25 +0000
committerGitHub <noreply@github.com>2024-10-29 11:41:25 +0000
commit06664fdc7680f7f9fa9b0a414a8fb8df2f913d48 (patch)
tree405438f642cf30465140a9abc354f227eae0fbce /llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
parent98c8d643539194321f3dba8698e95999165b1024 (diff)
downloadllvm-06664fdc7680f7f9fa9b0a414a8fb8df2f913d48.zip
llvm-06664fdc7680f7f9fa9b0a414a8fb8df2f913d48.tar.gz
llvm-06664fdc7680f7f9fa9b0a414a8fb8df2f913d48.tar.bz2
[FuncSpec] Enable SpecializeLiteralConstant by default (#113442)
Enable specialization on literal constant arguments by default in Function Specialization. --------- Co-authored-by: Alexandros Lamprineas <alexandros.lamprineas@arm.com>
Diffstat (limited to 'llvm/lib/Transforms/IPO/FunctionSpecialization.cpp')
-rw-r--r--llvm/lib/Transforms/IPO/FunctionSpecialization.cpp20
1 files changed, 9 insertions, 11 deletions
diff --git a/llvm/lib/Transforms/IPO/FunctionSpecialization.cpp b/llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
index 48971e9..8e6993d 100644
--- a/llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
+++ b/llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
@@ -84,14 +84,11 @@ static cl::opt<bool> SpecializeOnAddress(
"funcspec-on-address", cl::init(false), cl::Hidden, cl::desc(
"Enable function specialization on the address of global values"));
-// Disabled by default as it can significantly increase compilation times.
-//
-// https://llvm-compile-time-tracker.com
-// https://github.com/nikic/llvm-compile-time-tracker
static cl::opt<bool> SpecializeLiteralConstant(
- "funcspec-for-literal-constant", cl::init(false), cl::Hidden, cl::desc(
- "Enable specialization of functions that take a literal constant as an "
- "argument"));
+ "funcspec-for-literal-constant", cl::init(true), cl::Hidden,
+ cl::desc(
+ "Enable specialization of functions that take a literal constant as an "
+ "argument"));
bool InstCostVisitor::canEliminateSuccessor(BasicBlock *BB, BasicBlock *Succ,
DenseSet<BasicBlock *> &DeadBlocks) {
@@ -682,10 +679,11 @@ bool FunctionSpecializer::run() {
(RequireMinSize && Metrics.NumInsts < MinFunctionSize))
continue;
- // TODO: For now only consider recursive functions when running multiple
- // times. This should change if specialization on literal constants gets
- // enabled.
- if (!Inserted && !Metrics.isRecursive && !SpecializeLiteralConstant)
+ // When specialization on literal constants is disabled, only consider
+ // recursive functions when running multiple times to save wasted analysis,
+ // as we will not be able to specialize on any newly found literal constant
+ // return values.
+ if (!SpecializeLiteralConstant && !Inserted && !Metrics.isRecursive)
continue;
int64_t Sz = *Metrics.NumInsts.getValue();