[PATCH] D109294: [Inline] Remove dead users before checking if function has one use (PR51667)

Erik Desjardins via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 7 19:01:30 PDT 2021


erikdesjardins added inline comments.


================
Comment at: llvm/lib/Analysis/InlineCost.cpp:1862
 
+  F.removeDeadConstantUsers();
   bool OnlyOneCallAndLocalLinkage =
----------------
mtrofin wrote:
> aeubanks wrote:
> > mtrofin wrote:
> > > nikic wrote:
> > > > aeubanks wrote:
> > > > > mtrofin wrote:
> > > > > > From a separation of concerns perspective, I think this should rather happen after a successful inline, rather than when computing cost.
> > > > > +1, an analysis shouldn't be changing the IR
> > > > This already happens after a successful inline. The problem is that we also need it to happen before the hasOneUse() check below. The operation could be move to the point where the cost model is queried though.
> > > Hmm... IIUC, right now, after the first time a callee is inlined, removeDeadConstantUsers() is called, and next time its cost is computed it'll be accurate. The problem is the first time, correct? Does this feel like a normalization pass is missing, i.e. before inlining, we go over all functions in a module and removeDeadConstantUsers()?
> > Could you move this to before `Advisor.getAdvice()` in `InlinerPass::run()`?
> wouldn't that still do it more than the necessary number of times? 
Moved to before `Advisor.getAdvice()`


================
Comment at: llvm/test/Transforms/Inline/inline-cost-dead-users.ll:9
+
+; CHECK: 'f' inlined into 'h' with (cost=-15035, threshold=337)
+; CHECK: 'g' inlined into 'h' with (cost=-15035, threshold=337)
----------------
aeubanks wrote:
> hardcoding costs isn't ideal
> perhaps check that the cost/threshold is the same between the two inline pass remarks?
Makes sense. Done


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109294



More information about the llvm-commits mailing list