diff options
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp | 34 |
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); + } +} |