[llvm] [MemProf] Support for random hotness when writing profile (PR #113998)
Snehasish Kumar via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 29 12:30:04 PDT 2024
================
@@ -273,13 +291,37 @@ void InstrProfWriter::addRecord(StringRef Name, uint64_t Hash,
void InstrProfWriter::addMemProfRecord(
const Function::GUID Id, const memprof::IndexedMemProfRecord &Record) {
- auto [Iter, Inserted] = MemProfData.Records.insert({Id, Record});
+ auto NewRecord = Record;
+ // Provoke random hotness values if requested. We specify the lifetime access
+ // density and lifetime length that will result in a cold or not cold hotness.
+ // See the logic in getAllocType() in Analysis/MemoryProfileInfo.cpp.
+ if (MemprofGenerateRandomHotness) {
+ for (auto &Alloc : NewRecord.AllocSites) {
+ uint64_t NewTLAD = 0;
----------------
snehasish wrote:
If you initialize NewTLAD to `NewTLAD = std::numeric_limits<uint64_t>::max();` here instead then you can skip the else below. Also hoist the comment out of the else block.
https://github.com/llvm/llvm-project/pull/113998
More information about the llvm-commits
mailing list