aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
diff options
context:
space:
mode:
authorDaniel Paoliello <danpao@microsoft.com>2023-09-27 14:06:22 -0700
committerGitHub <noreply@github.com>2023-09-27 14:06:22 -0700
commit050bb26174cd9eb60c3c192476091494604f9a5d (patch)
treec7d537a46f144a6807557c69c96fec1f2b4b68f4 /llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
parenta82368ca7b221c2f4d251158aceccb189ede61e6 (diff)
downloadllvm-050bb26174cd9eb60c3c192476091494604f9a5d.zip
llvm-050bb26174cd9eb60c3c192476091494604f9a5d.tar.gz
llvm-050bb26174cd9eb60c3c192476091494604f9a5d.tar.bz2
[llvm] Implement S_INLINEES debug symbol (#67490)
The `S_INLINEES` debug symbol is used to record all the functions that are directly inlined within the current function (nested inlining is ignored). This change implements support for emitting the `S_INLINEES` debug symbol in LLVM, and cleans up how the `S_INLINEES` and `S_CALLEES` debug symbols are dumped.
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp34
1 files changed, 33 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
index b25a38b..335eccb 100644
--- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -250,7 +250,10 @@ CodeViewDebug::getInlineSite(const DILocation *InlinedAt,
InlinedAt->getLine(), InlinedAt->getColumn(), SMLoc());
Site->Inlinee = Inlinee;
InlinedSubprograms.insert(Inlinee);
- getFuncIdForSubprogram(Inlinee);
+ auto InlineeIdx = getFuncIdForSubprogram(Inlinee);
+
+ if (InlinedAt->getInlinedAt() == nullptr)
+ CurFn->Inlinees.insert(InlineeIdx);
}
return *Site;
}
@@ -1194,6 +1197,7 @@ void CodeViewDebug::emitDebugInfoForFunction(const Function *GV,
OS.emitInt32(uint32_t(FI.FrameProcOpts));
endSymbolRecord(FrameProcEnd);
+ emitInlinees(FI.Inlinees);
emitLocalVariableList(FI, FI.Locals);
emitGlobalVariableList(FI.Globals);
emitLexicalBlockList(FI.ChildBlocks, FI);
@@ -3588,3 +3592,31 @@ void CodeViewDebug::emitDebugInfoForJumpTables(const FunctionInfo &FI) {
endSymbolRecord(JumpTableEnd);
}
}
+
+void CodeViewDebug::emitInlinees(
+ const SmallSet<codeview::TypeIndex, 1> &Inlinees) {
+ // Divide the list of inlinees into chunks such that each chunk fits within
+ // one record.
+ constexpr auto ChunkSize =
+ (MaxRecordLength - sizeof(SymbolKind) - sizeof(uint32_t)) /
+ sizeof(uint32_t);
+
+ SmallVector<TypeIndex> SortedInlinees{Inlinees.begin(), Inlinees.end()};
+ llvm::sort(SortedInlinees);
+
+ uint64_t CurrentIndex = 0;
+ while (CurrentIndex < SortedInlinees.size()) {
+ auto Symbol = beginSymbolRecord(SymbolKind::S_INLINEES);
+ auto CurrentChunkSize =
+ std::min(ChunkSize, SortedInlinees.size() - CurrentIndex);
+ OS.AddComment("Count");
+ OS.emitInt32(CurrentChunkSize);
+
+ const uint64_t CurrentChunkEnd = CurrentIndex + CurrentChunkSize;
+ for (; CurrentIndex < CurrentChunkEnd; ++CurrentIndex) {
+ OS.AddComment("Inlinee");
+ OS.emitInt32(SortedInlinees[CurrentIndex].getIndex());
+ }
+ endSymbolRecord(Symbol);
+ }
+}