From 61c75eb6372786e5bc4025bd9023376fded76bf2 Mon Sep 17 00:00:00 2001 From: Snehasish Kumar Date: Tue, 22 Mar 2022 13:56:30 -0700 Subject: [PATCH] [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 --- compiler-rt/include/profile/MemProfData.inc | 36 +++++++++++++++++---------- llvm/include/llvm/ProfileData/MemProfData.inc | 36 +++++++++++++++++---------- 2 files changed, 46 insertions(+), 26 deletions(-) diff --git a/compiler-rt/include/profile/MemProfData.inc b/compiler-rt/include/profile/MemProfData.inc index 38698be9..6433cef 100644 --- a/compiler-rt/include/profile/MemProfData.inc +++ b/compiler-rt/include/profile/MemProfData.inc @@ -106,19 +106,29 @@ bool operator==(const MemInfoBlock& Other) const { 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; } diff --git a/llvm/include/llvm/ProfileData/MemProfData.inc b/llvm/include/llvm/ProfileData/MemProfData.inc index 38698be9..6433cef 100644 --- a/llvm/include/llvm/ProfileData/MemProfData.inc +++ b/llvm/include/llvm/ProfileData/MemProfData.inc @@ -106,19 +106,29 @@ bool operator==(const MemInfoBlock& Other) const { 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; } -- 2.7.4