Skip to content

Commit fe6c025

Browse files
committed
[nfc][ctx_prof] Fix the second source of nondeterminism in CtxProfAnalysisPrinterPass
Verified on a build with `LLVM_REVERSE_ITERATION=ON` Issue #106855
1 parent eef8116 commit fe6c025

File tree

4 files changed

+7
-8
lines changed

4 files changed

+7
-8
lines changed

llvm/include/llvm/Analysis/CtxProfAnalysis.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class CtxProfAnalysis;
2525
// counter, and then, because all contexts belonging to a function have the same
2626
// size, there'll be at most one other heap allocation.
2727
using CtxProfFlatProfile =
28-
DenseMap<GlobalValue::GUID, SmallVector<uint64_t, 1>>;
28+
std::map<GlobalValue::GUID, SmallVector<uint64_t, 1>>;
2929

3030
/// The instrumented contextual profile, produced by the CtxProfAnalysis.
3131
class PGOContextualProfile {

llvm/lib/Transforms/Instrumentation/PGOCtxProfFlattening.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -330,13 +330,12 @@ PreservedAnalyses PGOCtxProfFlatteningPass::run(Module &M,
330330
"Function has unreacheable basic blocks. The expectation was that "
331331
"DCE was run before.");
332332

333-
const auto &FlatProfile =
334-
FlattenedProfile.lookup(AssignGUIDPass::getGUID(F));
333+
auto It = FlattenedProfile.find(AssignGUIDPass::getGUID(F));
335334
// If this function didn't appear in the contextual profile, it's cold.
336-
if (FlatProfile.empty())
335+
if (It == FlattenedProfile.end())
337336
clearColdFunctionProfile(F);
338337
else {
339-
ProfileAnnotator S(F, FlatProfile, PB);
338+
ProfileAnnotator S(F, It->second, PB);
340339
S.assignProfileData();
341340
}
342341
}

llvm/test/Analysis/CtxProfAnalysis/full-cycle.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ Current Profile:
172172
]
173173

174174
Flat Profile:
175-
10507721908651011566 : 1
175+
2072045998141807037 : 7
176176
3087265239403591524 : 11 9
177177
4197650231481825559 : 2
178-
2072045998141807037 : 7
178+
10507721908651011566 : 1

llvm/test/Analysis/CtxProfAnalysis/load.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ Current Profile:
9090

9191
Flat Profile:
9292
728453322856651412 : 6 7
93-
12074870348631550642 : 5
9493
11872291593386833696 : 1
94+
12074870348631550642 : 5
9595
;--- example.ll
9696
declare void @bar()
9797

0 commit comments

Comments
 (0)