[PATCH] Don't Promote Args for Variadic Functions

Reid Kleckner rnk at google.com
Mon Aug 25 15:46:14 PDT 2014


Hm, now I understand the problem. I wouldn't say that the stack size is hardcoded into the IR in any way, though. The issue is that adding / removing / promoting non-pack parameters changes the classification of pack parameters. The classification of arguments at the call site is decided at compile time by clang, and the classification in the callee is determined dynamically by clang's expansion of va_arg.

DAE already knows this:
    Liveness Result;
    if (F.getFunctionType()->isVarArg()) {
      // Variadic functions will already have a va_arg function expanded inside
      // them, making them potentially very sensitive to ABI changes resulting
      // from removing arguments entirely, so don't. For example AArch64 handles
      // register and stack HFAs very differently, and this is reflected in the
      // IR which has already been generated.
      Result = Live;

For some reason argument promotion doesn't know this, even though it also removes dead arguments. I'm a bit surprised at the duplicated functionality, honestly.

http://reviews.llvm.org/D5055






More information about the llvm-commits mailing list