[llvm] [memprof] Teach extractCallsFromIR to recognize heap allocation functions (PR #115938)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 12 13:52:19 PST 2024
================
@@ -820,16 +820,26 @@ memprof::extractCallsFromIR(Module &M) {
continue;
StringRef CalleeName = CalledFunction->getName();
+ bool IsAlloc =
+ isAllocationWithHotColdVariant(CalledFunction, GetTLI(F));
for (const DILocation *DIL = I.getDebugLoc(); DIL;
DIL = DIL->getInlinedAt()) {
StringRef CallerName = DIL->getSubprogramLinkageName();
assert(!CallerName.empty() &&
"Be sure to enable -fdebug-info-for-profiling");
uint64_t CallerGUID = IndexedMemProfRecord::getGUID(CallerName);
uint64_t CalleeGUID = IndexedMemProfRecord::getGUID(CalleeName);
+ // Pretend that we are calling a function with GUID == 0 if we are
+ // calling a heap allocation function.
+ if (IsAlloc)
+ CalleeGUID = 0;
LineLocation Loc = {GetOffset(DIL), DIL->getColumn()};
Calls[CallerGUID].emplace_back(Loc, CalleeGUID);
CalleeName = CallerName;
+ // FIXME: Recognize other frames that are associated with heap
+ // allocation functions. It may be too early to reset IsAlloc to
+ // false here.
+ IsAlloc = false;
----------------
kazutakahirata wrote:
Discussed offline.
https://github.com/llvm/llvm-project/pull/115938
More information about the llvm-commits
mailing list