[all-commits] [llvm/llvm-project] e8984f: [Inlining] Teach shouldBeDeferred to take the tota...

kazutakahirata via All-commits all-commits at lists.llvm.org
Tue May 5 11:02:47 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: e8984fe65b949c6e3fcb41053ed7e5bcd2fe11e1
      https://github.com/llvm/llvm-project/commit/e8984fe65b949c6e3fcb41053ed7e5bcd2fe11e1
  Author: Kazu Hirata <kazu at google.com>
  Date:   2020-05-05 (Tue, 05 May 2020)

  Changed paths:
    M llvm/lib/Transforms/IPO/Inliner.cpp

  Log Message:
  -----------
  [Inlining] Teach shouldBeDeferred to take the total cost into account

Summary:
This patch teaches shouldBeDeferred to take into account the total
cost of inlining.

Suppose we have a call hierarchy {A1,A2,A3,...}->B->C.  (Each of A1,
A2, A3, ... calls B, which in turn calls C.)

Without this patch, shouldBeDeferred essentially returns true if

  TotalSecondaryCost < IC.getCost()

where TotalSecondaryCost is the total cost of inlining B into As.
This means that if B is a small wraper function, for example, it would
get inlined into all of As.  In turn, C gets inlined into all of As.
In other words, shouldBeDeferred ignores the cost of inlining C into
each of As.

This patch adds an option, inline-deferral-scale, to replace the
expression above with:

  TotalCost < Allowance

where

- TotalCost is TotalSecondaryCost + IC.getCost() * # of As, and
- Allowance is IC.getCost() * Scale

For now, the new option defaults to -1, disabling the new scheme.

Reviewers: davidxl

Subscribers: eraman, hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D79138




More information about the All-commits mailing list