diff options
author | Mingming Liu <mingmingl@google.com> | 2024-05-08 15:48:40 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-08 15:48:40 -0700 |
commit | 64f4ceb09ec3559368dd775330184b5259531cd3 (patch) | |
tree | 76e5fa048acb97f20d0b22c7b6a1d099a92a8c5d /llvm/lib/Transforms/Utils/InlineFunction.cpp | |
parent | 1610eaad39ad882f006f32c29771862a610f8314 (diff) | |
download | llvm-64f4ceb09ec3559368dd775330184b5259531cd3.zip llvm-64f4ceb09ec3559368dd775330184b5259531cd3.tar.gz llvm-64f4ceb09ec3559368dd775330184b5259531cd3.tar.bz2 |
[Inline][PGO] After inline, update InvokeInst profile counts in caller and cloned callee (#83809)
A related change is https://reviews.llvm.org/D133121, which correctly
preserves both branch weights and value profiles for invoke instruction.
* If the branch weight of the `invokeinst` specifies taken / not-taken branches, there is no scale.
Diffstat (limited to 'llvm/lib/Transforms/Utils/InlineFunction.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/InlineFunction.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp index 1aae561..48bb76e 100644 --- a/llvm/lib/Transforms/Utils/InlineFunction.cpp +++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp @@ -1982,10 +1982,14 @@ void llvm::updateProfileCallee( // During inlining ? if (VMap) { uint64_t CloneEntryCount = PriorEntryCount - NewEntryCount; - for (auto Entry : *VMap) + for (auto Entry : *VMap) { if (isa<CallInst>(Entry.first)) if (auto *CI = dyn_cast_or_null<CallInst>(Entry.second)) CI->updateProfWeight(CloneEntryCount, PriorEntryCount); + if (isa<InvokeInst>(Entry.first)) + if (auto *II = dyn_cast_or_null<InvokeInst>(Entry.second)) + II->updateProfWeight(CloneEntryCount, PriorEntryCount); + } } if (EntryDelta) { @@ -1994,9 +1998,12 @@ void llvm::updateProfileCallee( for (BasicBlock &BB : *Callee) // No need to update the callsite if it is pruned during inlining. if (!VMap || VMap->count(&BB)) - for (Instruction &I : BB) + for (Instruction &I : BB) { if (CallInst *CI = dyn_cast<CallInst>(&I)) CI->updateProfWeight(NewEntryCount, PriorEntryCount); + if (InvokeInst *II = dyn_cast<InvokeInst>(&I)) + II->updateProfWeight(NewEntryCount, PriorEntryCount); + } } } |