[clang] [compiler-rt] [llvm] [TypeProf][InstrFDO]Implement more efficient comparison sequence for indirect-call-promotion with vtable profiles. (PR #81442)
Mingming Liu via cfe-commits
cfe-commits at lists.llvm.org
Thu May 30 11:14:29 PDT 2024
================
@@ -1967,11 +1969,23 @@ void llvm::updateProfileCallee(
uint64_t CloneEntryCount = PriorEntryCount - NewEntryCount;
for (auto Entry : *VMap) {
if (isa<CallInst>(Entry.first))
- if (auto *CI = dyn_cast_or_null<CallInst>(Entry.second))
+ if (auto *CI = dyn_cast_or_null<CallInst>(Entry.second)) {
----------------
minglotus-6 wrote:
Makes sense to not further duplicate the code. How about something like this?
```
if (isa<CallBase>(Entry.first)) {
if(auto* CB = dyn_cast_or_null<CallBase>(Entry.Base)) {
CB->updateProfWeight(...
Instruction* VPtr = PGOIndirectCallVisitor::tryGetVTableInstruction(CB);
if (VPtr)
scaleProfData(VPtr...)
}
```
`CallBase` is the base class of five IR instructions [1] now. Among them `CoroAwaitSuspendInst` [1] and `GCStatePointInst` [2] are relatively new; the rest three are well understood. Despite more derived classes of `CallBase` might be added for new cases, the code above should be future-proof since `updateProfWeight` and `scaleProfData` are programmed to `!prof` (not `CallBase`).
[1]
https://github.com/llvm/llvm-project/blob/692ae5443b1778e138527ef55d799a4b535a36f9/llvm/lib/Transforms/Coroutines/CoroInstr.h#L85-L88
[2]
https://github.com/llvm/llvm-project/blob/692ae5443b1778e138527ef55d799a4b535a36f9/llvm/include/llvm/IR/Statepoint.h#L61-L63
https://github.com/llvm/llvm-project/pull/81442
More information about the cfe-commits
mailing list