diff options
author | Hari Limaye <hari.limaye@arm.com> | 2024-10-18 09:21:19 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-18 09:21:19 +0100 |
commit | 0d1a91e8f91e364b83f77e597dfb835d70fe9cf9 (patch) | |
tree | b576ac41f4e857b21d014e3908f26a1b286b148e /llvm/lib/Transforms/IPO/FunctionSpecialization.cpp | |
parent | abfba7d2e6a3cb0f1d0c976898447957dbbca6e0 (diff) | |
download | llvm-0d1a91e8f91e364b83f77e597dfb835d70fe9cf9.zip llvm-0d1a91e8f91e364b83f77e597dfb835d70fe9cf9.tar.gz llvm-0d1a91e8f91e364b83f77e597dfb835d70fe9cf9.tar.bz2 |
[FuncSpec] Update MinFunctionSize logic (#112711)
Always require functions to be larger than MinFunctionSize when
SpecializeLiteralConstant is enabled, and increase MinFunctionSize to
500, to prevent excessive triggering of specialisations on small
functions.
Diffstat (limited to 'llvm/lib/Transforms/IPO/FunctionSpecialization.cpp')
-rw-r--r-- | llvm/lib/Transforms/IPO/FunctionSpecialization.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/IPO/FunctionSpecialization.cpp b/llvm/lib/Transforms/IPO/FunctionSpecialization.cpp index bd0a337..7feebbe 100644 --- a/llvm/lib/Transforms/IPO/FunctionSpecialization.cpp +++ b/llvm/lib/Transforms/IPO/FunctionSpecialization.cpp @@ -57,9 +57,9 @@ static cl::opt<unsigned> MaxBlockPredecessors( "considered during the estimation of dead code")); static cl::opt<unsigned> MinFunctionSize( - "funcspec-min-function-size", cl::init(300), cl::Hidden, cl::desc( - "Don't specialize functions that have less than this number of " - "instructions")); + "funcspec-min-function-size", cl::init(500), cl::Hidden, + cl::desc("Don't specialize functions that have less than this number of " + "instructions")); static cl::opt<unsigned> MaxCodeSizeGrowth( "funcspec-max-codesize-growth", cl::init(3), cl::Hidden, cl::desc( @@ -641,12 +641,17 @@ bool FunctionSpecializer::run() { Metrics.analyzeBasicBlock(&BB, GetTTI(F), EphValues); } + // When specializing literal constants is enabled, always require functions + // to be larger than MinFunctionSize, to prevent excessive specialization. + const bool RequireMinSize = + !ForceSpecialization && + (SpecializeLiteralConstant || !F.hasFnAttribute(Attribute::NoInline)); + // If the code metrics reveal that we shouldn't duplicate the function, // or if the code size implies that this function is easy to get inlined, // then we shouldn't specialize it. if (Metrics.notDuplicatable || !Metrics.NumInsts.isValid() || - (!ForceSpecialization && !F.hasFnAttribute(Attribute::NoInline) && - Metrics.NumInsts < MinFunctionSize)) + (RequireMinSize && Metrics.NumInsts < MinFunctionSize)) continue; // TODO: For now only consider recursive functions when running multiple |