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

Snehasish Kumar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 22 13:59:50 PDT 2022


snehasish created this revision.
snehasish added a reviewer: tejohnson.
Herald added a project: All.
snehasish requested review of this revision.
Herald added projects: Sanitizers, LLVM.
Herald added subscribers: llvm-commits, Sanitizers.

This patch updates the existing default no-arg constructor for
MemInfoBlock to explicitly initialize all members. Also add missing
DataTypeId initialization to the other constructor. These issues were
exposed by msan on patch D121179 <https://reviews.llvm.org/D121179>. With this patch D121179 <https://reviews.llvm.org/D121179> builds cleanly
on msan.


Repository:
  rG LLVM Github Monorepo

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,7 +106,11 @@
   return IsEqual;
 }
 
-MemInfoBlock() : AllocCount(0) {}
+MemInfoBlock() {
+#define MIBEntryDef(NameTag, Name, Type) Name = Type();
+#include "MIBEntryDef.inc"
+#undef MIBEntryDef
+}
 
 MemInfoBlock(uint32_t size, uint64_t access_count, uint32_t alloc_timestamp,
              uint32_t dealloc_timestamp, uint32_t alloc_cpu, uint32_t dealloc_cpu)
@@ -118,7 +122,7 @@
       MinLifetime(TotalLifetime), MaxLifetime(TotalLifetime),
       AllocCpuId(alloc_cpu), DeallocCpuId(dealloc_cpu),
       NumLifetimeOverlaps(0), NumSameAllocCpu(0),
-      NumSameDeallocCpu(0) {
+      NumSameDeallocCpu(0), DataTypeId(0) {
   NumMigratedCpu = AllocCpuId != DeallocCpuId;
 }
 
Index: compiler-rt/include/profile/MemProfData.inc
===================================================================
--- compiler-rt/include/profile/MemProfData.inc
+++ compiler-rt/include/profile/MemProfData.inc
@@ -106,7 +106,11 @@
   return IsEqual;
 }
 
-MemInfoBlock() : AllocCount(0) {}
+MemInfoBlock() {
+#define MIBEntryDef(NameTag, Name, Type) Name = Type();
+#include "MIBEntryDef.inc"
+#undef MIBEntryDef
+}
 
 MemInfoBlock(uint32_t size, uint64_t access_count, uint32_t alloc_timestamp,
              uint32_t dealloc_timestamp, uint32_t alloc_cpu, uint32_t dealloc_cpu)
@@ -118,7 +122,7 @@
       MinLifetime(TotalLifetime), MaxLifetime(TotalLifetime),
       AllocCpuId(alloc_cpu), DeallocCpuId(dealloc_cpu),
       NumLifetimeOverlaps(0), NumSameAllocCpu(0),
-      NumSameDeallocCpu(0) {
+      NumSameDeallocCpu(0), DataTypeId(0) {
   NumMigratedCpu = AllocCpuId != DeallocCpuId;
 }
 


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


More information about the llvm-commits mailing list