[llvm-commits] [patch] Support "inreg sret"

Rafael EspĂ­ndola rafael.espindola at gmail.com
Tue Jul 24 13:44:26 PDT 2012


I am trying to fix some ABI issues with the regparm attribute on X86.
In particular, gcc compiles

struct s {
  double x1;
  float x2;
};
__attribute__((regparm(3))) struct s f(int a, int b, int c);
void g(void) {
  f(41, 42, 43);
}

to

g:
	subl	$40, %esp
	movl	$42, %ecx
	pushl	$43
	movl	$41, %edx
	leal	16(%esp), %eax
	call	f
	addl	$44, %esp
	ret

Note how the return struct is passed indirectly, but is passed in the
first register (eax). The values 41 and 42 are passed in the following
registers (edx, ecx) and 43 is passed on the stack. I think the
correct representation at the llvm level is

declare void @f(%struct.s* inreg sret, i32 inreg, i32 inreg, i32)

The attached patch adds support for it. I will send the clang patch
for review in a moment.

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


More information about the llvm-commits mailing list