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

Sunil Srivastava via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 19 14:32:18 PDT 2017


Sunil_Srivastava added inline comments.
This revision now requires changes to proceed.


================
Comment at: lib/Analysis/InlineCost.cpp:903
+      // If A calls a variadic function B and B has a musttail call to C, then
+      // C can do va_start and access args passed from A to B against '...'.
+      // Therefore we can not inline B inside A.
----------------
hfinkel wrote:
> Really? Does the LangRef guarantee this?
First, I must admit that I do not fully know where musttail calls are used. I believe they are used for thunks.

LangRef does not even have the concept of musttail, so I can not answer your question precisely.

I am trying to be conservative and try to prevent C from accessing A-to-B unnamed arguments via some builtins or some other way in a situation like this:

void C(int x, ...) // actual user code.
{
  va_start(ap, x); 
  assert(va_arg(ap, int) == 5);
}
void B(int a, ...)  // a thunk meant to jump to C
{
  .. do something. Maybe a+=4 ..
  C(a, ....); // musttail call somehow. Essentially a jump to C
}
void A(int x){
  B(a, 5);
}

Now if we inline B into A, we will throw away 5 before C is even entered. Therefore I want to prevent B-into-A inlining.


https://reviews.llvm.org/D22529





More information about the llvm-commits mailing list