[cfe-commits] [patch][pr13436] Fix some uses of regparm on X86

Rafael EspĂ­ndola rafael.espindola at gmail.com
Tue Jul 24 14:24:34 PDT 2012


I found that clang's implementation of regparm doesn't match gcc's
when the argument is a struct. Clang just skips the struct, gcc splits
it in 32 bit chunks that are passed in registers. Not too different
from the x86-64 abi.

In a bit more detail, it looks like gcc does the following:

* Arguments of type float, double, {float} and {double} are classified as
Float, and every other argument type is classified as Integer.
* Float arguments are passed on the stack and don't consume registers.
* If an integer argument fits completely in the remaining registers, it is
passed in registers, otherwise it goes to the stack.
* Integer arguments consume registers even if they don't fit, so once an
argument goes to the stack every other argument goes to the stack.
* A struct return is still done indirectly, but the pointer is passed
as the first argument in registers.

This patch implements this. Note that it depends on the patch I just
posted to the llvm list.

Cheers,
Rafael
-------------- next part --------------
A non-text attachment was scrubbed...
Name: t.patch
Type: application/octet-stream
Size: 16897 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120724/6fcbb699/attachment.obj>


More information about the cfe-commits mailing list