@@ -342,6 +342,28 @@ using CallStackId = uint64_t;
342342// A type representing the index into the call stack array.
343343using LinearCallStackId = uint32_t ;
344344
345+ // Holds call site information with indexed frame contents.
346+ struct IndexedCallSiteInfo {
347+ // The call stack ID for this call site
348+ CallStackId CSId = 0 ;
349+ // The GUIDs of the callees at this call site
350+ SmallVector<GlobalValue::GUID, 1 > CalleeGuids;
351+
352+ IndexedCallSiteInfo () = default ;
353+ IndexedCallSiteInfo (CallStackId CSId) : CSId(CSId) {}
354+ IndexedCallSiteInfo (CallStackId CSId,
355+ SmallVector<GlobalValue::GUID, 1 > CalleeGuids)
356+ : CSId(CSId), CalleeGuids(std::move(CalleeGuids)) {}
357+
358+ bool operator ==(const IndexedCallSiteInfo &Other) const {
359+ return CSId == Other.CSId && CalleeGuids == Other.CalleeGuids ;
360+ }
361+
362+ bool operator !=(const IndexedCallSiteInfo &Other) const {
363+ return !operator ==(Other);
364+ }
365+ };
366+
345367// Holds allocation information in a space efficient format where frames are
346368// represented using unique identifiers.
347369struct IndexedAllocationInfo {
@@ -410,7 +432,7 @@ struct IndexedMemProfRecord {
410432 // list of inline locations in bottom-up order i.e. from leaf to root. The
411433 // inline location list may include additional entries, users should pick
412434 // the last entry in the list with the same function GUID.
413- llvm::SmallVector<CallStackId> CallSiteIds ;
435+ llvm::SmallVector<IndexedCallSiteInfo> CallSites ;
414436
415437 void clear () { *this = IndexedMemProfRecord (); }
416438
@@ -427,7 +449,7 @@ struct IndexedMemProfRecord {
427449 if (Other.AllocSites != AllocSites)
428450 return false ;
429451
430- if (Other.CallSiteIds != CallSiteIds )
452+ if (Other.CallSites != CallSites )
431453 return false ;
432454 return true ;
433455 }
@@ -455,14 +477,37 @@ struct IndexedMemProfRecord {
455477 static GlobalValue::GUID getGUID (const StringRef FunctionName);
456478};
457479
480+ // Holds call site information with frame contents inline.
481+ struct CallSiteInfo {
482+ // The frames in the call stack
483+ std::vector<Frame> Frames;
484+
485+ // The GUIDs of the callees at this call site
486+ SmallVector<GlobalValue::GUID, 1 > CalleeGuids;
487+
488+ CallSiteInfo () = default ;
489+ CallSiteInfo (std::vector<Frame> Frames) : Frames(std::move(Frames)) {}
490+ CallSiteInfo (std::vector<Frame> Frames,
491+ SmallVector<GlobalValue::GUID, 1 > CalleeGuids)
492+ : Frames(std::move(Frames)), CalleeGuids(std::move(CalleeGuids)) {}
493+
494+ bool operator ==(const CallSiteInfo &Other) const {
495+ return Frames == Other.Frames && CalleeGuids == Other.CalleeGuids ;
496+ }
497+
498+ bool operator !=(const CallSiteInfo &Other) const {
499+ return !operator ==(Other);
500+ }
501+ };
502+
458503// Holds the memprof profile information for a function. The internal
459504// representation stores frame contents inline. This representation should
460505// be used for small amount of temporary, in memory instances.
461506struct MemProfRecord {
462507 // Same as IndexedMemProfRecord::AllocSites with frame contents inline.
463508 llvm::SmallVector<AllocationInfo> AllocSites;
464509 // Same as IndexedMemProfRecord::CallSites with frame contents inline.
465- llvm::SmallVector<std::vector<Frame> > CallSites;
510+ llvm::SmallVector<CallSiteInfo > CallSites;
466511
467512 MemProfRecord () = default ;
468513
@@ -476,8 +521,8 @@ struct MemProfRecord {
476521
477522 if (!CallSites.empty ()) {
478523 OS << " CallSites:\n " ;
479- for (const std::vector<Frame> &Frames : CallSites) {
480- for (const Frame &F : Frames) {
524+ for (const CallSiteInfo &CS : CallSites) {
525+ for (const Frame &F : CS. Frames ) {
481526 OS << " -\n " ;
482527 F.printYAML (OS);
483528 }
0 commit comments