[PATCH] D30651: [InlineCost, -Oz] Don't take into account the penalty of a fast call of frequently used functions

Evgeny Astigeevich via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 6 12:42:19 PST 2017


eastig added a comment.

In https://reviews.llvm.org/D30651#693418, @efriedma wrote:

> Special-casing calls marked "fast" doesn't really make sense in general.  For example, on ARM v6-M, "fast" is exactly the same as the C calling convention.


More precise, the code from GlobalOpt:

  static bool isProfitableToMakeFastCC(Function *F) {
    CallingConv::ID CC = F->getCallingConv();
    // FIXME: Is it worth transforming x86_stdcallcc and x86_fastcallcc?
    return CC == CallingConv::C || CC == CallingConv::X86_ThisCall;
  }

You are mixing up the idea of fast calls and what is marked as a fast call. According to the http://llvm.org/docs/LangRef.html#calling-conventions:

> “fastcc” - The fast calling convention
>  This calling convention attempts to make calls as fast as possible (e.g. by passing things in registers). This calling convention allows the target to use whatever tricks it wants to produce fast code for the target, without having to conform to an externally specified ABI (Application Binary Interface). Tail calls can only be optimized when this, the GHC or the HiPE convention is used. This calling convention does not support varargs and requires the prototype of all callees to exactly match the prototype of the function definition.

Why not to use this information? Based on this we can expect fast calls will have minimized call overhead.

> That said, adding an inliner special-case to inline internal functions with two or three callers more aggressively might make sense, similar to the existing bonus for inlining internal functions with exactly one caller.  (This might have a similar effect to your patch because calls marked "fast" generally are calling functions with internal linkage.)

If a call is not marked as a call with a low call overhead we should not assume this. 
Also we can mark calls as fastcc based on additional heuristics or target knowledge.


https://reviews.llvm.org/D30651





More information about the llvm-commits mailing list