[memprof] Initialize MemInfoBlock data.

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. With this patch D121179 builds cleanly
on msan.

Reviewed By: tejohnson

Differential Revision: https://reviews.llvm.org/D122260
This commit is contained in:
Snehasish Kumar 2022-03-22 13:56:30 -07:00
parent 9933015fdd
commit 61c75eb637
2 changed files with 44 additions and 24 deletions

View File

@ -106,19 +106,29 @@ bool operator==(const MemInfoBlock& Other) const {
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)
: 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(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;
}

View File

@ -106,19 +106,29 @@ bool operator==(const MemInfoBlock& Other) const {
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)
: 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(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;
}