[llvm] fe6c025 - [nfc][ctx_prof] Fix the second source of nondeterminism in `CtxProfAnalysisPrinterPass`
Mircea Trofin via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 6 21:54:31 PDT 2024
Author: Mircea Trofin
Date: 2024-09-06T21:54:23-07:00
New Revision: fe6c025037f0b2b52725b5e912dbda9eb3371ad3
URL: https://github.com/llvm/llvm-project/commit/fe6c025037f0b2b52725b5e912dbda9eb3371ad3
DIFF: https://github.com/llvm/llvm-project/commit/fe6c025037f0b2b52725b5e912dbda9eb3371ad3.diff
LOG: [nfc][ctx_prof] Fix the second source of nondeterminism in `CtxProfAnalysisPrinterPass`
Verified on a build with `LLVM_REVERSE_ITERATION=ON`
Issue #106855
Added:
Modified:
llvm/include/llvm/Analysis/CtxProfAnalysis.h
llvm/lib/Transforms/Instrumentation/PGOCtxProfFlattening.cpp
llvm/test/Analysis/CtxProfAnalysis/full-cycle.ll
llvm/test/Analysis/CtxProfAnalysis/load.ll
Removed:
################################################################################
diff --git a/llvm/include/llvm/Analysis/CtxProfAnalysis.h b/llvm/include/llvm/Analysis/CtxProfAnalysis.h
index 850c27d902776e..d3b7ba96e4faa5 100644
--- a/llvm/include/llvm/Analysis/CtxProfAnalysis.h
+++ b/llvm/include/llvm/Analysis/CtxProfAnalysis.h
@@ -25,7 +25,7 @@ class CtxProfAnalysis;
// counter, and then, because all contexts belonging to a function have the same
// size, there'll be at most one other heap allocation.
using CtxProfFlatProfile =
- DenseMap<GlobalValue::GUID, SmallVector<uint64_t, 1>>;
+ std::map<GlobalValue::GUID, SmallVector<uint64_t, 1>>;
/// The instrumented contextual profile, produced by the CtxProfAnalysis.
class PGOContextualProfile {
diff --git a/llvm/lib/Transforms/Instrumentation/PGOCtxProfFlattening.cpp b/llvm/lib/Transforms/Instrumentation/PGOCtxProfFlattening.cpp
index d62ca53af862b1..fc78d8c60ec050 100644
--- a/llvm/lib/Transforms/Instrumentation/PGOCtxProfFlattening.cpp
+++ b/llvm/lib/Transforms/Instrumentation/PGOCtxProfFlattening.cpp
@@ -330,13 +330,12 @@ PreservedAnalyses PGOCtxProfFlatteningPass::run(Module &M,
"Function has unreacheable basic blocks. The expectation was that "
"DCE was run before.");
- const auto &FlatProfile =
- FlattenedProfile.lookup(AssignGUIDPass::getGUID(F));
+ auto It = FlattenedProfile.find(AssignGUIDPass::getGUID(F));
// If this function didn't appear in the contextual profile, it's cold.
- if (FlatProfile.empty())
+ if (It == FlattenedProfile.end())
clearColdFunctionProfile(F);
else {
- ProfileAnnotator S(F, FlatProfile, PB);
+ ProfileAnnotator S(F, It->second, PB);
S.assignProfileData();
}
}
diff --git a/llvm/test/Analysis/CtxProfAnalysis/full-cycle.ll b/llvm/test/Analysis/CtxProfAnalysis/full-cycle.ll
index eb59e93241fd32..905e7eea9f49ee 100644
--- a/llvm/test/Analysis/CtxProfAnalysis/full-cycle.ll
+++ b/llvm/test/Analysis/CtxProfAnalysis/full-cycle.ll
@@ -172,7 +172,7 @@ Current Profile:
]
Flat Profile:
-10507721908651011566 : 1
+2072045998141807037 : 7
3087265239403591524 : 11 9
4197650231481825559 : 2
-2072045998141807037 : 7
+10507721908651011566 : 1
diff --git a/llvm/test/Analysis/CtxProfAnalysis/load.ll b/llvm/test/Analysis/CtxProfAnalysis/load.ll
index 3e29d41fc9570d..0cf6c5973dc6b5 100644
--- a/llvm/test/Analysis/CtxProfAnalysis/load.ll
+++ b/llvm/test/Analysis/CtxProfAnalysis/load.ll
@@ -90,8 +90,8 @@ Current Profile:
Flat Profile:
728453322856651412 : 6 7
-12074870348631550642 : 5
11872291593386833696 : 1
+12074870348631550642 : 5
;--- example.ll
declare void @bar()
More information about the llvm-commits
mailing list