[PATCH] D122844: [llvm-profgen] Fixing a context attribure update issue due to a non-derministic processing order on different platforms.

Hongtao Yu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 31 12:50:49 PDT 2022


hoy updated this revision to Diff 419549.
hoy added a comment.

Updating D122844 <https://reviews.llvm.org/D122844>: [llvm-profgen] Fixing a context attribure update issue due to a non-derministic processing order on different platforms.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D122844/new/

https://reviews.llvm.org/D122844

Files:
  llvm/tools/llvm-profgen/ProfileGenerator.cpp


Index: llvm/tools/llvm-profgen/ProfileGenerator.cpp
===================================================================
--- llvm/tools/llvm-profgen/ProfileGenerator.cpp
+++ llvm/tools/llvm-profgen/ProfileGenerator.cpp
@@ -712,7 +712,23 @@
     FunctionSamples &FProfile = Ret.first->second;
     FProfile.setContext(FContext);
     return Ret.first->second;
+  } else {
+    // Update ContextWasInlined attribute for existing contexts. A context can
+    // be created by invoking this function in two ways:
+    //  - by using a probe and its calling context.
+    //  - by removing the leaf frame from an existing contexts.
+    // The first way is used when generating a function profile for a given LBR
+    // range, and the input `WasLeafInlined` is computed depending on the
+    // actually probe in the LBR range. The second way is used when using the
+    // entry count of an inlinee function profile to update its inliner callsite
+    // count, so `WasLeafInlined` is unknown for the inliner frame. The two
+    // invocations can happen in any order, and here we are making sure
+    // `ContextWasInlined` is always set correctly.
+    FunctionSamples &FProfile = I->second;
+    if (WasLeafInlined)
+      FProfile.getContext().setAttribute(ContextWasInlined);
   }
+
   return I->second;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122844.419549.patch
Type: text/x-patch
Size: 1310 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220331/3346010a/attachment.bin>


More information about the llvm-commits mailing list