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 4ULL
39#define MEMPROF_RAW_SUPPORTED_VERSIONS \
42#define MEMPROF_V3_MIB_SIZE 132ULL;
44#define MEMPROF_BUILDID_MAX_SIZE 32ULL
60PACKED(
struct SegmentEntry {
65 uint8_t BuildId[MEMPROF_BUILDID_MAX_SIZE] = {0};
71 SegmentEntry(
const SegmentEntry& S) {
75 BuildIdSize = S.BuildIdSize;
76 memcpy(BuildId, S.BuildId, S.BuildIdSize);
79 SegmentEntry& operator=(
const SegmentEntry& S) {
83 BuildIdSize = S.BuildIdSize;
84 memcpy(BuildId, S.BuildId, S.BuildIdSize);
90 BuildIdSize == S.BuildIdSize &&
91 memcmp(BuildId, S.BuildId, S.BuildIdSize) == 0;
108#define MIBEntryDef(NameTag, Name, Type) Type Name;
114#define MIBEntryDef(NameTag, Name, Type) \
115 IsEqual = (IsEqual && Name == Other.Name);
122#define MIBEntryDef(NameTag, Name, Type) Name = Type();
129 uintptr_t Histogram,
uint32_t HistogramSize)
132 TotalAccessCount = AccessCount;
133 MinAccessCount = AccessCount;
134 MaxAccessCount = AccessCount;
138 AllocTimestamp = AllocTs;
139 DeallocTimestamp = DeallocTs;
140 TotalLifetime = DeallocTimestamp - AllocTimestamp;
141 MinLifetime = TotalLifetime;
142 MaxLifetime = TotalLifetime;
145 TotalAccessDensity = AccessCount * 100 /
Size;
146 MinAccessDensity = TotalAccessDensity;
147 MaxAccessDensity = TotalAccessDensity;
152 TotalLifetimeAccessDensity =
153 TotalAccessDensity * 1000 / (TotalLifetime ? TotalLifetime : 1);
154 MinLifetimeAccessDensity = TotalLifetimeAccessDensity;
155 MaxLifetimeAccessDensity = TotalLifetimeAccessDensity;
156 AllocCpuId = AllocCpu;
157 DeallocCpuId = DeallocCpu;
158 NumMigratedCpu = AllocCpuId != DeallocCpuId;
159 AccessHistogramSize = HistogramSize;
160 AccessHistogram = Histogram;
163void Merge(
const MemInfoBlock &newMIB) {
164 AllocCount += newMIB.AllocCount;
166 TotalAccessCount += newMIB.TotalAccessCount;
167 MinAccessCount = newMIB.MinAccessCount < MinAccessCount ? newMIB.MinAccessCount : MinAccessCount;
168 MaxAccessCount = newMIB.MaxAccessCount > MaxAccessCount ? newMIB.MaxAccessCount : MaxAccessCount;
170 TotalSize += newMIB.TotalSize;
171 MinSize = newMIB.MinSize < MinSize ? newMIB.MinSize : MinSize;
172 MaxSize = newMIB.MaxSize > MaxSize ? newMIB.MaxSize : MaxSize;
174 TotalLifetime += newMIB.TotalLifetime;
175 MinLifetime = newMIB.MinLifetime < MinLifetime ? newMIB.MinLifetime : MinLifetime;
176 MaxLifetime = newMIB.MaxLifetime > MaxLifetime ? newMIB.MaxLifetime : MaxLifetime;
178 TotalAccessDensity += newMIB.TotalAccessDensity;
179 MinAccessDensity = newMIB.MinAccessDensity < MinAccessDensity
180 ? newMIB.MinAccessDensity
182 MaxAccessDensity = newMIB.MaxAccessDensity > MaxAccessDensity
183 ? newMIB.MaxAccessDensity
186 TotalLifetimeAccessDensity += newMIB.TotalLifetimeAccessDensity;
187 MinLifetimeAccessDensity =
188 newMIB.MinLifetimeAccessDensity < MinLifetimeAccessDensity
189 ? newMIB.MinLifetimeAccessDensity
190 : MinLifetimeAccessDensity;
191 MaxLifetimeAccessDensity =
192 newMIB.MaxLifetimeAccessDensity > MaxLifetimeAccessDensity
193 ? newMIB.MaxLifetimeAccessDensity
194 : MaxLifetimeAccessDensity;
198 NumLifetimeOverlaps += newMIB.AllocTimestamp < DeallocTimestamp;
199 AllocTimestamp = newMIB.AllocTimestamp;
200 DeallocTimestamp = newMIB.DeallocTimestamp;
202 NumSameAllocCpu += AllocCpuId == newMIB.AllocCpuId;
203 NumSameDeallocCpu += DeallocCpuId == newMIB.DeallocCpuId;
204 AllocCpuId = newMIB.AllocCpuId;
205 DeallocCpuId = newMIB.DeallocCpuId;
209 uintptr_t ShorterHistogram;
211 if (newMIB.AccessHistogramSize > AccessHistogramSize) {
212 ShorterHistogram = AccessHistogram;
213 ShorterHistogramSize = AccessHistogramSize;
215 AccessHistogram = newMIB.AccessHistogram;
216 AccessHistogramSize = newMIB.AccessHistogramSize;
218 ShorterHistogram = newMIB.AccessHistogram;
219 ShorterHistogramSize = newMIB.AccessHistogramSize;
221 for (
size_t i = 0; i < ShorterHistogramSize; ++i) {
227} __pragma(pack(pop));
229} __attribute__((__packed__));
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
std::optional< std::vector< StOtherPiece > > Other
Merge contiguous icmps into a memcmp
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)