@@ -250,7 +250,10 @@ CodeViewDebug::getInlineSite(const DILocation *InlinedAt,
250250 InlinedAt->getLine (), InlinedAt->getColumn (), SMLoc ());
251251 Site->Inlinee = Inlinee;
252252 InlinedSubprograms.insert (Inlinee);
253- getFuncIdForSubprogram (Inlinee);
253+ auto InlineeIdx = getFuncIdForSubprogram (Inlinee);
254+
255+ if (InlinedAt->getInlinedAt () == nullptr )
256+ CurFn->Inlinees .insert (InlineeIdx);
254257 }
255258 return *Site;
256259}
@@ -1194,6 +1197,7 @@ void CodeViewDebug::emitDebugInfoForFunction(const Function *GV,
11941197 OS.emitInt32 (uint32_t (FI.FrameProcOpts ));
11951198 endSymbolRecord (FrameProcEnd);
11961199
1200+ emitInlinees (FI.Inlinees );
11971201 emitLocalVariableList (FI, FI.Locals );
11981202 emitGlobalVariableList (FI.Globals );
11991203 emitLexicalBlockList (FI.ChildBlocks , FI);
@@ -3588,3 +3592,31 @@ void CodeViewDebug::emitDebugInfoForJumpTables(const FunctionInfo &FI) {
35883592 endSymbolRecord (JumpTableEnd);
35893593 }
35903594}
3595+
3596+ void CodeViewDebug::emitInlinees (
3597+ const SmallSet<codeview::TypeIndex, 1 > &Inlinees) {
3598+ // Divide the list of inlinees into chunks such that each chunk fits within
3599+ // one record.
3600+ constexpr auto ChunkSize =
3601+ (MaxRecordLength - sizeof (SymbolKind) - sizeof (uint32_t )) /
3602+ sizeof (uint32_t );
3603+
3604+ SmallVector<TypeIndex> SortedInlinees{Inlinees.begin (), Inlinees.end ()};
3605+ llvm::sort (SortedInlinees);
3606+
3607+ uint64_t CurrentIndex = 0 ;
3608+ while (CurrentIndex < SortedInlinees.size ()) {
3609+ auto Symbol = beginSymbolRecord (SymbolKind::S_INLINEES);
3610+ auto CurrentChunkSize =
3611+ std::min (ChunkSize, SortedInlinees.size () - CurrentIndex);
3612+ OS.AddComment (" Count" );
3613+ OS.emitInt32 (CurrentChunkSize);
3614+
3615+ const uint64_t CurrentChunkEnd = CurrentIndex + CurrentChunkSize;
3616+ for (; CurrentIndex < CurrentChunkEnd; ++CurrentIndex) {
3617+ OS.AddComment (" Inlinee" );
3618+ OS.emitInt32 (SortedInlinees[CurrentIndex].getIndex ());
3619+ }
3620+ endSymbolRecord (Symbol);
3621+ }
3622+ }
0 commit comments