[PATCH] D22529: Inlining of empty/small variadic functions.

Sunil Srivastava via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 19 13:47:08 PDT 2016


Sunil_Srivastava created this revision.
Sunil_Srivastava added reviewers: sanjoy, rsmith, chandlerc.
Sunil_Srivastava added a subscriber: llvm-commits.

This is a fix for PR27796, inlining of empty/small variadic

While the general problem of inlining variadic functions is difficult, it is quite easy to inline variadic functions if they do not use va_start, because in those cases we can simply ignore arguments passed against '...'. That use pattern, though seemingly wasteful, is actually quite useful for writing functions for trace messages, with bodies that are removed via conditional compilation in production builds. This is done with the expectation that the compiler will inline these essentially empty functions and optimize out entire tracing overhead.

That is the purpose of this proposed change.

The determination of whether a the called function if using va_start is done at the time of inlining by scanning the code of the called function. However, in order to avoid the cost of this extra scan, we limit this scan to 'small' function; the definition of 'small' being that it must have a single block of no more that 20 instructions. Larger callees are rejected without full scan. That is sufficient for our use cases of mostly empty functions. The choice of 20 for number of instructions is somewhat arbitrary.

https://reviews.llvm.org/D22529

Files:
  lib/Transforms/Utils/InlineFunction.cpp
  test/Transforms/Inline/inline-varargs.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22529.64554.patch
Type: text/x-patch
Size: 9658 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160719/adc8ded4/attachment.bin>


More information about the llvm-commits mailing list