[PATCH] D122260: [memprof] Initialize MemInfoBlock data.

Snehasish Kumar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 22 14:30:01 PDT 2022


snehasish updated this revision to Diff 417406.
snehasish added a comment.

Address comments.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D122260/new/

https://reviews.llvm.org/D122260

Files:
  compiler-rt/include/profile/MemProfData.inc
  llvm/include/llvm/ProfileData/MemProfData.inc


Index: llvm/include/llvm/ProfileData/MemProfData.inc
===================================================================
--- llvm/include/llvm/ProfileData/MemProfData.inc
+++ llvm/include/llvm/ProfileData/MemProfData.inc
@@ -106,19 +106,29 @@
   return IsEqual;
 }
 
-MemInfoBlock() : AllocCount(0) {}
-
-MemInfoBlock(uint32_t size, uint64_t access_count, uint32_t alloc_timestamp,
-             uint32_t dealloc_timestamp, uint32_t alloc_cpu, uint32_t dealloc_cpu)
-    : AllocCount(1), TotalAccessCount(access_count),
-      MinAccessCount(access_count), MaxAccessCount(access_count),
-      TotalSize(size), MinSize(size), MaxSize(size),
-      AllocTimestamp(alloc_timestamp), DeallocTimestamp(dealloc_timestamp),
-      TotalLifetime(dealloc_timestamp - alloc_timestamp),
-      MinLifetime(TotalLifetime), MaxLifetime(TotalLifetime),
-      AllocCpuId(alloc_cpu), DeallocCpuId(dealloc_cpu),
-      NumLifetimeOverlaps(0), NumSameAllocCpu(0),
-      NumSameDeallocCpu(0) {
+MemInfoBlock() {
+#define MIBEntryDef(NameTag, Name, Type) Name = Type();
+#include "MIBEntryDef.inc"
+#undef MIBEntryDef
+}
+
+MemInfoBlock(uint32_t Size, uint64_t AccessCount, uint32_t AllocTs,
+             uint32_t DeallocTs, uint32_t AllocCpu, uint32_t DeallocCpu)
+    : MemInfoBlock() {
+  AllocCount = 1U;
+  TotalAccessCount = AccessCount;
+  MinAccessCount = AccessCount;
+  MaxAccessCount = AccessCount;
+  TotalSize = Size;
+  MinSize = Size;
+  MaxSize = Size;
+  AllocTimestamp = AllocTs;
+  DeallocTimestamp = DeallocTs;
+  TotalLifetime = DeallocTimestamp - AllocTimestamp;
+  MinLifetime = TotalLifetime;
+  MaxLifetime = TotalLifetime;
+  AllocCpuId = AllocCpu;
+  DeallocCpuId = DeallocCpu;
   NumMigratedCpu = AllocCpuId != DeallocCpuId;
 }
 
Index: compiler-rt/include/profile/MemProfData.inc
===================================================================
--- compiler-rt/include/profile/MemProfData.inc
+++ compiler-rt/include/profile/MemProfData.inc
@@ -106,19 +106,29 @@
   return IsEqual;
 }
 
-MemInfoBlock() : AllocCount(0) {}
-
-MemInfoBlock(uint32_t size, uint64_t access_count, uint32_t alloc_timestamp,
-             uint32_t dealloc_timestamp, uint32_t alloc_cpu, uint32_t dealloc_cpu)
-    : AllocCount(1), TotalAccessCount(access_count),
-      MinAccessCount(access_count), MaxAccessCount(access_count),
-      TotalSize(size), MinSize(size), MaxSize(size),
-      AllocTimestamp(alloc_timestamp), DeallocTimestamp(dealloc_timestamp),
-      TotalLifetime(dealloc_timestamp - alloc_timestamp),
-      MinLifetime(TotalLifetime), MaxLifetime(TotalLifetime),
-      AllocCpuId(alloc_cpu), DeallocCpuId(dealloc_cpu),
-      NumLifetimeOverlaps(0), NumSameAllocCpu(0),
-      NumSameDeallocCpu(0) {
+MemInfoBlock() {
+#define MIBEntryDef(NameTag, Name, Type) Name = Type();
+#include "MIBEntryDef.inc"
+#undef MIBEntryDef
+}
+
+MemInfoBlock(uint32_t Size, uint64_t AccessCount, uint32_t AllocTs,
+             uint32_t DeallocTs, uint32_t AllocCpu, uint32_t DeallocCpu)
+    : MemInfoBlock() {
+  AllocCount = 1U;
+  TotalAccessCount = AccessCount;
+  MinAccessCount = AccessCount;
+  MaxAccessCount = AccessCount;
+  TotalSize = Size;
+  MinSize = Size;
+  MaxSize = Size;
+  AllocTimestamp = AllocTs;
+  DeallocTimestamp = DeallocTs;
+  TotalLifetime = DeallocTimestamp - AllocTimestamp;
+  MinLifetime = TotalLifetime;
+  MaxLifetime = TotalLifetime;
+  AllocCpuId = AllocCpu;
+  DeallocCpuId = DeallocCpu;
   NumMigratedCpu = AllocCpuId != DeallocCpuId;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122260.417406.patch
Type: text/x-patch
Size: 3478 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220322/a1d8ba89/attachment.bin>


More information about the llvm-commits mailing list