aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
diff options
context:
space:
mode:
authorAlan Zhao <ayzhao@google.com>2025-09-10 23:22:21 -0700
committerGitHub <noreply@github.com>2025-09-11 06:22:21 +0000
commitbf6debcfe18866269eb370f470d84e010957171b (patch)
treef09b3908768797bd224afa85cf50681cface17ae /llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
parent6a719387704c8c01b29bdb418a4d8a3b5df6b090 (diff)
downloadllvm-bf6debcfe18866269eb370f470d84e010957171b.zip
llvm-bf6debcfe18866269eb370f470d84e010957171b.tar.gz
llvm-bf6debcfe18866269eb370f470d84e010957171b.tar.bz2
[FunctionSpecialization] Fix profile count preserving logic (#157939)
The previous fix in #157768 had a bug; instead of subtracting the original function's call count per call site of a specialization, we were subtracting the running total of the specialization's calls. Tracking issue: #147390
Diffstat (limited to 'llvm/lib/Transforms/IPO/FunctionSpecialization.cpp')
-rw-r--r--llvm/lib/Transforms/IPO/FunctionSpecialization.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/IPO/FunctionSpecialization.cpp b/llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
index 30459ca..20d3993 100644
--- a/llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
+++ b/llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
@@ -802,8 +802,8 @@ bool FunctionSpecializer::run() {
if (std::optional<llvm::Function::ProfileCount> MaybeOriginalCount =
S.F->getEntryCount()) {
uint64_t OriginalCount = MaybeOriginalCount->getCount();
- if (OriginalCount >= CallCount) {
- S.F->setEntryCount(OriginalCount - CallCount);
+ if (OriginalCount >= *Count) {
+ S.F->setEntryCount(OriginalCount - *Count);
} else {
// This should generally not happen as that would mean there are
// more computed calls to the function than what was recorded.