[llvm] 644c902 - [ctx_prof] Fix nondeterminism in CtxProfAnalysisPrinterPass

Mircea Trofin via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 6 19:23:16 PDT 2024


Author: Mircea Trofin
Date: 2024-09-06T19:22:21-07:00
New Revision: 644c9020ff6fac98cbffcbf33c7e273f14670658

URL: https://github.com/llvm/llvm-project/commit/644c9020ff6fac98cbffcbf33c7e273f14670658
DIFF: https://github.com/llvm/llvm-project/commit/644c9020ff6fac98cbffcbf33c7e273f14670658.diff

LOG: [ctx_prof] Fix nondeterminism in CtxProfAnalysisPrinterPass

Using a `std::map` instead of a `DenseMap` for the FuncInfo
member.

Addresses the ctx_prof part of Issue #106855

Added: 
    

Modified: 
    llvm/include/llvm/Analysis/CtxProfAnalysis.h
    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 80edd19ea8f8f8..850c27d902776e 100644
--- a/llvm/include/llvm/Analysis/CtxProfAnalysis.h
+++ b/llvm/include/llvm/Analysis/CtxProfAnalysis.h
@@ -41,7 +41,7 @@ class PGOContextualProfile {
   std::optional<PGOCtxProfContext::CallTargetMapTy> Profiles;
   // For the GUIDs in this module, associate metadata about each function which
   // we'll need when we maintain the profiles during IPO transformations.
-  DenseMap<GlobalValue::GUID, FunctionInfo> FuncInfo;
+  std::map<GlobalValue::GUID, FunctionInfo> FuncInfo;
 
   /// Get the GUID of this Function if it's defined in this module.
   GlobalValue::GUID getDefinedFunctionGUID(const Function &F) const;

diff  --git a/llvm/test/Analysis/CtxProfAnalysis/full-cycle.ll b/llvm/test/Analysis/CtxProfAnalysis/full-cycle.ll
index 5284f3a3c7c4e2..eb59e93241fd32 100644
--- a/llvm/test/Analysis/CtxProfAnalysis/full-cycle.ll
+++ b/llvm/test/Analysis/CtxProfAnalysis/full-cycle.ll
@@ -116,10 +116,10 @@ define void @entrypoint() {
 ]
 ;--- expected.txt
 Function Info:
-10507721908651011566 : entrypoint. MaxCounterID: 1. MaxCallsiteID: 2
+2072045998141807037 : f1. MaxCounterID: 1. MaxCallsiteID: 1
 3087265239403591524 : f2.llvm.0. MaxCounterID: 1. MaxCallsiteID: 0
 4197650231481825559 : f3. MaxCounterID: 1. MaxCallsiteID: 1
-2072045998141807037 : f1. MaxCounterID: 1. MaxCallsiteID: 1
+10507721908651011566 : entrypoint. MaxCounterID: 1. MaxCallsiteID: 2
 
 Current Profile:
 [

diff  --git a/llvm/test/Analysis/CtxProfAnalysis/load.ll b/llvm/test/Analysis/CtxProfAnalysis/load.ll
index 7d92f9678e7c3c..3e29d41fc9570d 100644
--- a/llvm/test/Analysis/CtxProfAnalysis/load.ll
+++ b/llvm/test/Analysis/CtxProfAnalysis/load.ll
@@ -58,8 +58,8 @@
 ;--- expected-profile-output.txt
 Function Info:
 4909520559318251808 : an_entrypoint. MaxCounterID: 2. MaxCallsiteID: 1
-12074870348631550642 : another_entrypoint_no_callees. MaxCounterID: 1. MaxCallsiteID: 0
 11872291593386833696 : foo. MaxCounterID: 1. MaxCallsiteID: 1
+12074870348631550642 : another_entrypoint_no_callees. MaxCounterID: 1. MaxCallsiteID: 0
 
 Current Profile:
 [


        


More information about the llvm-commits mailing list