|
37 | 37 |
|
38 | 38 | using namespace llvm; |
39 | 39 |
|
40 | | -static cl::opt<bool> |
41 | | - MemprofGenerateRandomHotness("memprof-random-hotness", cl::init(false), |
42 | | - cl::Hidden, |
43 | | - cl::desc("Generate random hotness values")); |
44 | | -static cl::opt<unsigned> MemprofGenerateRandomHotnessSeed( |
45 | | - "memprof-random-hotness-seed", cl::init(0), cl::Hidden, |
46 | | - cl::desc("Random hotness seed to use (0 to generate new seed)")); |
47 | | - |
48 | 40 | // A struct to define how the data stream should be patched. For Indexed |
49 | 41 | // profiling, only uint64_t data type is needed. |
50 | 42 | struct PatchItem { |
@@ -193,13 +185,16 @@ class InstrProfRecordWriterTrait { |
193 | 185 | InstrProfWriter::InstrProfWriter( |
194 | 186 | bool Sparse, uint64_t TemporalProfTraceReservoirSize, |
195 | 187 | uint64_t MaxTemporalProfTraceLength, bool WritePrevVersion, |
196 | | - memprof::IndexedVersion MemProfVersionRequested, bool MemProfFullSchema) |
| 188 | + memprof::IndexedVersion MemProfVersionRequested, bool MemProfFullSchema, |
| 189 | + bool MemprofGenerateRandomHotness, |
| 190 | + unsigned MemprofGenerateRandomHotnessSeed) |
197 | 191 | : Sparse(Sparse), MaxTemporalProfTraceLength(MaxTemporalProfTraceLength), |
198 | 192 | TemporalProfTraceReservoirSize(TemporalProfTraceReservoirSize), |
199 | 193 | InfoObj(new InstrProfRecordWriterTrait()), |
200 | 194 | WritePrevVersion(WritePrevVersion), |
201 | 195 | MemProfVersionRequested(MemProfVersionRequested), |
202 | | - MemProfFullSchema(MemProfFullSchema) { |
| 196 | + MemProfFullSchema(MemProfFullSchema), |
| 197 | + MemprofGenerateRandomHotness(MemprofGenerateRandomHotness) { |
203 | 198 | // Set up the random number seed if requested. |
204 | 199 | if (MemprofGenerateRandomHotness) { |
205 | 200 | unsigned seed = MemprofGenerateRandomHotnessSeed |
@@ -297,19 +292,16 @@ void InstrProfWriter::addMemProfRecord( |
297 | 292 | // See the logic in getAllocType() in Analysis/MemoryProfileInfo.cpp. |
298 | 293 | if (MemprofGenerateRandomHotness) { |
299 | 294 | for (auto &Alloc : NewRecord.AllocSites) { |
300 | | - uint64_t NewTLAD = 0; |
| 295 | + // To get a not cold context, set the lifetime access density to the |
| 296 | + // maximum value and the lifetime to 0. |
| 297 | + uint64_t NewTLAD = std::numeric_limits<uint64_t>::max(); |
301 | 298 | uint64_t NewTL = 0; |
302 | 299 | bool IsCold = std::rand() % 2; |
303 | 300 | if (IsCold) { |
304 | 301 | // To get a cold context, set the lifetime access density to 0 and the |
305 | 302 | // lifetime to the maximum value. |
306 | 303 | NewTLAD = 0; |
307 | 304 | NewTL = std::numeric_limits<uint64_t>::max(); |
308 | | - } else { |
309 | | - // To get a not cold context, set the lifetime access density to the |
310 | | - // maximum value and the lifetime to 0. |
311 | | - NewTLAD = std::numeric_limits<uint64_t>::max(); |
312 | | - NewTL = 0; |
313 | 305 | } |
314 | 306 | Alloc.Info.setTotalLifetimeAccessDensity(NewTLAD); |
315 | 307 | Alloc.Info.setTotalLifetime(NewTL); |
|
0 commit comments