[PATCH] D24338: [InlineCost] Remove CallPenalty and change MinSizeThreshold to 5

James Molloy via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 2 07:15:34 PDT 2016


jmolloy added a comment.

Hi all,

Thanks for the rush of comments! This has been on my back burner for a while, you've motivated me to try and push it forward :)

Having stared at this code for a long time now, my overall feeling is that, long term, we should try and move a lot of the inline cost logic around calls into TargetTransformInfo. TTI::getCallCost already does a similar cost calculation, just with fewer special cases. Doing this would allow the broad brush heuristics "CallPenalty" and "InliningMultiplier" to be removed entirely, as targets that cared about them could simply override getCallCost.

That's a large change however, and is likely to change cost calculations. The updated diff is essentially what you all have suggested, and I think gets us one stage of the way towards the longer term goal above.

Most uses of CallPenalty are moved into TargetTransformInfo, with a default value the same as InlineConstants::CallPenalty. InlineConstants::CallPenalty stays, because it is also used as a default cost for a soft-float library call (this could probably be renamed, thinking about it).

I've removed the skew by subtracting CallPenalty when setting up the initial threshold.

CallPenalty is calculated from TargetTransformInfo, but is overridable from the command line. This is very useful for inlining tests - while the penalty has a use in practice, when devising small testcases it does get in the way. This allows the testcases to stay small, and makes sense in most cases because the tests are already overriding the inlining cost.

This is the first step, and shouldn't cause much impact at all in performance. The overall effect is actually the same as my previous patchset, and I benchmarked that one very heavily and found no glaring performance issues.

The next step after this would be to sort out -Oz, which is affected by this change the most. It makes sense to reduce the call penalty to zero when optimizing purely for size (-Oz) and to change the -Oz inline threshold to zero to compensate. We'll then have sensibly modelled inlining behaviour when focussing on size.


Repository:
  rL LLVM

https://reviews.llvm.org/D24338





More information about the llvm-commits mailing list