Skip to content

[MemProf] Handle missing tail call frames #75823

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions llvm/include/llvm/IR/ModuleSummaryIndex.h
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,12 @@ class FunctionSummary : public GlobalValueSummary {
return *Callsites;
}

void addCallsite(CallsiteInfo &Callsite) {
if (!Callsites)
Callsites = std::make_unique<CallsitesTy>();
Callsites->push_back(Callsite);
}

ArrayRef<AllocInfo> allocs() const {
if (Allocs)
return *Allocs;
Expand Down
17 changes: 16 additions & 1 deletion llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -459,9 +459,24 @@ class IndexBitcodeWriter : public BitcodeWriterBase {
// Record all stack id indices actually used in the summary entries being
// written, so that we can compact them in the case of distributed ThinLTO
// indexes.
for (auto &CI : FS->callsites())
for (auto &CI : FS->callsites()) {
// If the stack id list is empty, this callsite info was synthesized for
// a missing tail call frame. Ensure that the callee's GUID gets a value
// id. Normally we only generate these for defined summaries, which in
// the case of distributed ThinLTO is only the functions already defined
// in the module or that we want to import. We don't bother to include
// all the callee symbols as they aren't normally needed in the backend.
// However, for the synthesized callsite infos we do need the callee
// GUID in the backend so that we can correlate the identified callee
// with this callsite info (which for non-tail calls is done by the
// ordering of the callsite infos and verified via stack ids).
if (CI.StackIdIndices.empty()) {
GUIDToValueIdMap[CI.Callee.getGUID()] = ++GlobalValueId;
continue;
}
for (auto Idx : CI.StackIdIndices)
StackIdIndices.push_back(Idx);
}
for (auto &AI : FS->allocs())
for (auto &MIB : AI.MIBs)
for (auto Idx : MIB.StackIdIndices)
Expand Down
Loading