[llvm-commits] [llvm-gcc-4.2] r86892 - /llvm-gcc-4.2/trunk/gcc/llvm-abi.h

Bob Wilson bob.wilson at apple.com
Wed Dec 2 14:26:35 PST 2009


On Dec 2, 2009, at 1:45 PM, Rafael Espindola wrote:

>> I don't have any testcases that are better than the one for pr5406.  I'm not sure if it is safe to access a 24-bit struct as an i32.
> 
> If it is not, that is (almost) a testcase :-)
> 
> Consider
> 
> -----------------
> struct foo {
> char[3] a;
> };
> 
> void f(struct foo x);
> void g(int a, int b, int c, int d, struct foo x);
> ----------------------
> 
> 
> We should expand this to
> 
> void @f(i32)
> and
> void @g(i32, i32, i32, i32, i16, i8)
> 
> That is, using i32 or i16 + i8 will depend on the value being on the
> stack on in a register. Given that we would have to change
> PassInIntegerRegisters to know what fraction of the type is being
> passed in registers  (or implement byval for arm).

Right.

I checked with ddunbar yesterday about how clang handles this, and it is currently passing the struct as an i32.  Whether that is safe may depend on how that i32 is created.  E.G., if clang constructs that i32 value by loading individual bytes from the struct, that should clearly be OK.  Depending on the ABI, it may be endian-dependent whether the struct is packed into the high or low bits of the i32.  I don't see any code to handle that, but it's quite possible I'm just missing it.

I'm hoping Dale will weigh in on this soon, but I'm tentatively planning to add the byval support as soon as I get a chance (which may be a while).



More information about the llvm-commits mailing list