[llvm] [nfc][ctx_prof] Efficient profile traversal and update (PR #110052)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 26 15:29:58 PDT 2024


================
@@ -279,16 +278,44 @@ static void preorderVisit(ProfilesTy &Profiles,
     Traverser(P);
 }
 
-void PGOContextualProfile::update(Visitor V, const Function *F) {
-  GlobalValue::GUID G = F ? getDefinedFunctionGUID(*F) : 0U;
+void PGOContextualProfile::initIndex() {
+  // Initialize the head of the index list for each function. We don't need it
+  // after this point.
+  DenseMap<GlobalValue::GUID, PGOCtxProfContext *> InsertionPoints;
----------------
kazutakahirata wrote:

Are you building this temporary data structure for performance reasons?  I see that `FuncInfo` uses `std::map` while `InsertionPoints` uses `DenseMap`.  IIUC, you could use `FuncInfo` directly in the call to `preorderVisit`.


https://github.com/llvm/llvm-project/pull/110052


More information about the llvm-commits mailing list