[PATCH] D84997: [AutoFDO] Avoid merging inlinee samples multiple times

Wenlei He via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 30 20:15:59 PDT 2020


wenlei accepted this revision.
wenlei added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks!



================
Comment at: llvm/lib/Transforms/IPO/SampleProfile.cpp:1107
     if (ProfileMergeInlinee) {
-      // Use entry samples as head samples during the merge, as inlinees
-      // don't have head samples.
-      assert(FS->getHeadSamples() == 0 && "Expect 0 head sample for inlinee");
-      const_cast<FunctionSamples *>(FS)->addHeadSamples(FS->getEntrySamples());
-
-      // Note that we have to do the merge right after processing function.
-      // This allows OutlineFS's profile to be used for annotation during
-      // top-down processing of functions' annotation.
-      FunctionSamples *OutlineFS = Reader->getOrCreateSamplesFor(*Callee);
-      OutlineFS->merge(*FS);
+      if (FS->getHeadSamples() == 0) {
+        // Use entry samples as head samples during the merge, as inlinees
----------------
A comment explain the check? e.g. we want to merge it exactly once as earlier pass may have duplicated the call site already, and when duplicating, we don't slicing the original inlinee's profile.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84997



More information about the llvm-commits mailing list