1#ifndef MEMPROF_DATA_INC
2#define MEMPROF_DATA_INC
25#define PACKED(...) __pragma(pack(push,1)) __VA_ARGS__ __pragma(pack(pop))
27#define PACKED(...) __VA_ARGS__ __attribute__((__packed__))
31#define MEMPROF_RAW_MAGIC_64 \
32 ((uint64_t)255 << 56 | (uint64_t)'m' << 48 | (uint64_t)'p' << 40 | (uint64_t)'r' << 32 | \
33 (uint64_t)'o' << 24 | (uint64_t)'f' << 16 | (uint64_t)'r' << 8 | (uint64_t)129)
36#define MEMPROF_RAW_VERSION 3ULL
38#define MEMPROF_BUILDID_MAX_SIZE 32ULL
54PACKED(
struct SegmentEntry {
59 uint8_t BuildId[MEMPROF_BUILDID_MAX_SIZE] = {0};
65 SegmentEntry(
const SegmentEntry& S) {
69 BuildIdSize = S.BuildIdSize;
70 memcpy(BuildId, S.BuildId, S.BuildIdSize);
73 SegmentEntry& operator=(
const SegmentEntry& S) {
77 BuildIdSize = S.BuildIdSize;
78 memcpy(BuildId, S.BuildId, S.BuildIdSize);
83 return Start == S.Start && End == S.End &&
Offset == S.Offset &&
84 BuildIdSize == S.BuildIdSize &&
85 memcmp(BuildId, S.BuildId, S.BuildIdSize) == 0;
102#define MIBEntryDef(NameTag, Name, Type) Type Name;
108#define MIBEntryDef(NameTag, Name, Type) \
109 IsEqual = (IsEqual && Name == Other.Name);
116#define MIBEntryDef(NameTag, Name, Type) Name = Type();
125 TotalAccessCount = AccessCount;
126 MinAccessCount = AccessCount;
127 MaxAccessCount = AccessCount;
131 AllocTimestamp = AllocTs;
132 DeallocTimestamp = DeallocTs;
133 TotalLifetime = DeallocTimestamp - AllocTimestamp;
134 MinLifetime = TotalLifetime;
135 MaxLifetime = TotalLifetime;
138 TotalAccessDensity = AccessCount * 100 /
Size;
139 MinAccessDensity = TotalAccessDensity;
140 MaxAccessDensity = TotalAccessDensity;
145 TotalLifetimeAccessDensity =
146 TotalAccessDensity * 1000 / (TotalLifetime ? TotalLifetime : 1);
147 MinLifetimeAccessDensity = TotalLifetimeAccessDensity;
148 MaxLifetimeAccessDensity = TotalLifetimeAccessDensity;
149 AllocCpuId = AllocCpu;
150 DeallocCpuId = DeallocCpu;
151 NumMigratedCpu = AllocCpuId != DeallocCpuId;
154void Merge(
const MemInfoBlock &newMIB) {
155 AllocCount += newMIB.AllocCount;
157 TotalAccessCount += newMIB.TotalAccessCount;
158 MinAccessCount = newMIB.MinAccessCount < MinAccessCount ? newMIB.MinAccessCount : MinAccessCount;
159 MaxAccessCount = newMIB.MaxAccessCount > MaxAccessCount ? newMIB.MaxAccessCount : MaxAccessCount;
161 TotalSize += newMIB.TotalSize;
162 MinSize = newMIB.MinSize < MinSize ? newMIB.MinSize : MinSize;
163 MaxSize = newMIB.MaxSize > MaxSize ? newMIB.MaxSize : MaxSize;
165 TotalLifetime += newMIB.TotalLifetime;
166 MinLifetime = newMIB.MinLifetime < MinLifetime ? newMIB.MinLifetime : MinLifetime;
167 MaxLifetime = newMIB.MaxLifetime > MaxLifetime ? newMIB.MaxLifetime : MaxLifetime;
169 TotalAccessDensity += newMIB.TotalAccessDensity;
170 MinAccessDensity = newMIB.MinAccessDensity < MinAccessDensity
171 ? newMIB.MinAccessDensity
173 MaxAccessDensity = newMIB.MaxAccessDensity > MaxAccessDensity
174 ? newMIB.MaxAccessDensity
177 TotalLifetimeAccessDensity += newMIB.TotalLifetimeAccessDensity;
178 MinLifetimeAccessDensity =
179 newMIB.MinLifetimeAccessDensity < MinLifetimeAccessDensity
180 ? newMIB.MinLifetimeAccessDensity
181 : MinLifetimeAccessDensity;
182 MaxLifetimeAccessDensity =
183 newMIB.MaxLifetimeAccessDensity > MaxLifetimeAccessDensity
184 ? newMIB.MaxLifetimeAccessDensity
185 : MaxLifetimeAccessDensity;
189 NumLifetimeOverlaps += newMIB.AllocTimestamp < DeallocTimestamp;
190 AllocTimestamp = newMIB.AllocTimestamp;
191 DeallocTimestamp = newMIB.DeallocTimestamp;
193 NumSameAllocCpu += AllocCpuId == newMIB.AllocCpuId;
194 NumSameDeallocCpu += DeallocCpuId == newMIB.DeallocCpuId;
195 AllocCpuId = newMIB.AllocCpuId;
196 DeallocCpuId = newMIB.DeallocCpuId;
200} __pragma(pack(pop));
202} __attribute__((__packed__));
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
std::optional< std::vector< StOtherPiece > > Other
Merge contiguous icmps into a memcmp
bool operator==(const StringView &LHS, const StringView &RHS)
static Constant * SegmentOffset(IRBuilderBase &IRB, int Offset, unsigned AddressSpace)
This is an optimization pass for GlobalISel generic memory operations.
bool operator==(const AddressRangeValuePair &LHS, const AddressRangeValuePair &RHS)