@@ -342,6 +342,28 @@ using CallStackId = uint64_t;
342
342
// A type representing the index into the call stack array.
343
343
using LinearCallStackId = uint32_t ;
344
344
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
+
345
367
// Holds allocation information in a space efficient format where frames are
346
368
// represented using unique identifiers.
347
369
struct IndexedAllocationInfo {
@@ -410,7 +432,7 @@ struct IndexedMemProfRecord {
410
432
// list of inline locations in bottom-up order i.e. from leaf to root. The
411
433
// inline location list may include additional entries, users should pick
412
434
// the last entry in the list with the same function GUID.
413
- llvm::SmallVector<CallStackId> CallSiteIds ;
435
+ llvm::SmallVector<IndexedCallSiteInfo> CallSites ;
414
436
415
437
void clear () { *this = IndexedMemProfRecord (); }
416
438
@@ -427,7 +449,7 @@ struct IndexedMemProfRecord {
427
449
if (Other.AllocSites != AllocSites)
428
450
return false ;
429
451
430
- if (Other.CallSiteIds != CallSiteIds )
452
+ if (Other.CallSites != CallSites )
431
453
return false ;
432
454
return true ;
433
455
}
@@ -455,14 +477,37 @@ struct IndexedMemProfRecord {
455
477
static GlobalValue::GUID getGUID (const StringRef FunctionName);
456
478
};
457
479
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
+
458
503
// Holds the memprof profile information for a function. The internal
459
504
// representation stores frame contents inline. This representation should
460
505
// be used for small amount of temporary, in memory instances.
461
506
struct MemProfRecord {
462
507
// Same as IndexedMemProfRecord::AllocSites with frame contents inline.
463
508
llvm::SmallVector<AllocationInfo> AllocSites;
464
509
// Same as IndexedMemProfRecord::CallSites with frame contents inline.
465
- llvm::SmallVector<std::vector<Frame> > CallSites;
510
+ llvm::SmallVector<CallSiteInfo > CallSites;
466
511
467
512
MemProfRecord () = default ;
468
513
@@ -476,8 +521,8 @@ struct MemProfRecord {
476
521
477
522
if (!CallSites.empty ()) {
478
523
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 ) {
481
526
OS << " -\n " ;
482
527
F.printYAML (OS);
483
528
}
0 commit comments