[cfe-dev] variable length argument functions in AMD64 arch

Eli Friedman eli.friedman at gmail.com
Thu Aug 13 14:39:38 PDT 2009


On Thu, Aug 13, 2009 at 1:26 PM, Zhi Wang<beiyuw at gmail.com> wrote:
> It seems clang will generate code to handle variable length arguments
> no matter whether
> va_xxx (va_start, va_end) is used or not. (gcc will only generate code
> to handle varible
> length arguments when va_start is used).

I suppose that's a quality-of-implementation issue; it's really more
of a backend issue, though, so I'd suggest asking on llvmdev.

> My biggest issue with this code is that movaps is used. According to
> Intel's manual,
> if the destination memory isn't 16-byte aligned, a GP# (General
> Protection fault) will occur.
> It seems that using movaps is wrong unless we can guarantee that ebp
> is always 16byte aligned.
> This may not be true. I manually edited the binary of generated code
> to use the movups
> (the same instruction as movups except that it will not check the
> alignment). instruction
> and everything is fine.

The stack is supposed to be 16-byte aligned on x86-64; if it isn't,
there's probably a bug somewhere.  But again, better to discuss on
llvmdev.

-Eli



More information about the cfe-dev mailing list