This is an archive of the discontinued LLVM Phabricator instance.

[InlineCost] CallPenalty knob to provide custom values
Needs ReviewPublic

Authored by eastig on Mar 13 2017, 9:37 AM.

Details

Summary

At the moment CallPenalty is fixed to the value 25.
The patch introduces a knob '-call-penalty' to provide custom values to CallPenalty.

Event Timeline

eastig created this revision.Mar 13 2017, 9:37 AM
efriedma added inline comments.Mar 13 2017, 6:01 PM
include/llvm/Analysis/InlineCost.h
80

It seems kind of weird to return the CallPenalty here... but I guess you need it in lib/Transforms/IPO/Inliner.cpp?

92

Using INT_MIN and INT_MAX seems like it's just asking for trouble with overflow... but I guess we don't actually use it in that case? Seems better to just use 0.

lib/Analysis/InlineCost.cpp
1235

The call penalty should be the same for every callsite; we shouldn't need to update it here... unless you're planning to change that?

eastig added inline comments.Mar 14 2017, 5:03 AM
include/llvm/Analysis/InlineCost.h
80

Yes, this is because of Inliner.cpp.
Should CallPenalty be a part of InlineParams?

  1. If no, then we know its value either default or cmd-option provided. In such case we can have a function accessing to CallPenalty defined in InlineCost.cpp.
  2. If yes, its value can be whatever a caller of llvm::getInlineCost has been provided. In such case we need to save the value somewhere. I chose this option. As InlineCost object is only way of communication I stored used CallPenalty in it as it's done for Threshold.

What about having it in TTI?

92

I used zeros in the initial version. Then I thought if I could use some values which could protect from incorrect uses. Like -infinity penalty means no penalty and no inline. +infinity means a lot of penalty and always inline.
I have nothing against using zeros.

lib/Analysis/InlineCost.cpp
1235

As I wrote above if the penalty is a part of InlineParams it can be different per a call. So we need to update the current value based on the value passed through InlineParams.

eraman added inline comments.Mar 14 2017, 4:40 PM
lib/Transforms/IPO/Inliner.cpp
292

r286814 subtracts CallPenalty while computing the inline cost (which is returned by IC.getCost()), but this code is not updated to reflect that. I think CandidateCost should be IC.getCost() - 1, which will eliminate the need for IC.getCallPenalty().

eastig added inline comments.Mar 15 2017, 2:40 AM
lib/Transforms/IPO/Inliner.cpp
292

Thank you for information. It makes things simpler. I'll have a look at this.