diff options
| author | Teresa Johnson <tejohnson@google.com> | 2024-01-11 06:57:48 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-01-11 06:57:48 -0800 |
| commit | 26a8664ed4573ef1559c4edc7b254a10d186d428 (patch) | |
| tree | 3e1bd55c07e7ffcceceb6fddbb9b9ead0c6609e4 /llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | |
| parent | dc717b19925c9e0a4fcca0ad277476400f62cc25 (diff) | |
| download | llvm-26a8664ed4573ef1559c4edc7b254a10d186d428.zip llvm-26a8664ed4573ef1559c4edc7b254a10d186d428.tar.gz llvm-26a8664ed4573ef1559c4edc7b254a10d186d428.tar.bz2 | |
[MemProf] Handle missing tail call frames (#75823)
If tail call optimization was not disabled for the profiled binary, the
call contexts will be missing frames for tail calls. Handle this by
performing a limited search through tail call edges for the profiled
callee when a discontinuity is detected. The search depth is adjustable
but defaults to 5.
If we are able to identify a short sequence of tail calls, update the
graph for those calls. In the case of ThinLTO, synthesize the necessary
CallsiteInfos for carrying the cloning information to the backends.
Diffstat (limited to 'llvm/lib/Bitcode/Writer/BitcodeWriter.cpp')
| -rw-r--r-- | llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp index 8fca569..a5fc267 100644 --- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -459,9 +459,24 @@ public: // 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) |
