[PATCH] D90056: [AutoFDO] Remove an assert when merging inlinee samples

Hongtao Yu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 23 09:49:47 PDT 2020


hoy created this revision.
Herald added subscribers: llvm-commits, wenlei, hiraditya.
Herald added a project: LLVM.
hoy requested review of this revision.

Duplicated callsites share the same callee profile if the original callsite was inlined. The sharing also causes the profile of callee's callee to be shared. This breaks the assert introduced ealier by D84997 <https://reviews.llvm.org/D84997> in a tricky way.

To illustrate, I'm using an abstract example. Say we have three functions `A`, `B` and `C`. A calls B twice and B calls C once. Some optimize performed prior to the sample profile loader duplicates first callsite to B and the program may look like

A()
{

  B();  // with nested profile B1 and C1
  B();  // duplicated, with nested profile B1 and C1
  B();  // with nested profile B2 and C2

}

For some reason, the sample profile loader inliner then decides to only inline the first callsite in A and transforms A into

A()
{

  C();  // with nested profile C1
  B();  // duplicated, with nested profile B1 and C1
  B();  // with nested profile B2 and C2.

}

Failing to inline the callsite C() would result in

In reality

Test Plan:


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90056

Files:
  llvm/lib/Transforms/IPO/SampleProfile.cpp


Index: llvm/lib/Transforms/IPO/SampleProfile.cpp
===================================================================
--- llvm/lib/Transforms/IPO/SampleProfile.cpp
+++ llvm/lib/Transforms/IPO/SampleProfile.cpp
@@ -1141,10 +1141,7 @@
         // top-down processing of functions' annotation.
         FunctionSamples *OutlineFS = Reader->getOrCreateSamplesFor(*Callee);
         OutlineFS->merge(*FS);
-      } else
-        assert(FS->getHeadSamples() == FS->getEntrySamples() &&
-               "Expect same head and entry sample counts for profiles already "
-               "merged.");
+      }
     } else {
       auto pair =
           notInlinedCallInfo.try_emplace(Callee, NotInlinedProfileInfo{0});


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90056.300331.patch
Type: text/x-patch
Size: 707 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201023/534151bc/attachment-0001.bin>


More information about the llvm-commits mailing list