[llvm] [FuncSpec] Only compute Latency bonus when necessary (PR #113159)
Hari Limaye via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 22 04:18:02 PDT 2024
================
@@ -889,18 +910,20 @@ bool FunctionSpecializer::findSpecializations(Function *F, unsigned FuncSize,
unsigned Score = 0;
InstCostVisitor Visitor = getInstCostVisitorFor(F);
for (ArgInfo &A : S.Args) {
- CodeSize += Visitor.getCodeSizeBonus(A.Formal, A.Actual);
+ CodeSize += Visitor.getCodeSizeSavingsForArg(A.Formal, A.Actual);
Score += getInliningBonus(A.Formal, A.Actual);
}
- CodeSize += Visitor.getCodeSizeBonusFromPendingPHIs();
+ CodeSize += Visitor.getCodeSizeSavingsFromPendingPHIs();
LLVM_DEBUG(dbgs() << "FnSpecialization: Specialization bonus {CodeSize = "
<< CodeSize << ", Inlining = " << Score << "}\n");
- Bonus B = {CodeSize, 0};
- FunctionGrowth[F] += FuncSize - B.CodeSize;
+ unsigned LatencySavings = 0;
+ unsigned CodeSizeSavings = getCostValue(CodeSize);
+ FunctionGrowth[F] += FuncSize - CodeSizeSavings;
----------------
hazzlim wrote:
I've sunk/moved things into the lambda and refactored it to just capture the scope by reference.
Note - I've realized that we accumulate the CodeSize increase into FunctionGrowth[F] for all specializations that we evaluate, rather than just the actual specializations we create. I've added a TODO for fixing this, as I think the changes would be non-trivial and don't make sense to do in this PR.
https://github.com/llvm/llvm-project/pull/113159
More information about the llvm-commits
mailing list