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

Bob Wilson bob.wilson at apple.com
Tue Dec 1 15:27:01 PST 2009


On Dec 1, 2009, at 3:06 PM, Rafael Espindola wrote:

>> Instead, I think the ARM backend needs to handle "byval" arguments.  That is how both x86 and ppc handle the testcase in pr5406.  I don't think it is possible to fix the PassInIntegerRegisters code to correctly handle aggregates that are not a multiple of the register size, at least not without much more extensive changes.  You either end up accessing memory past the end of the argument (as Dale pointed out earlier) or splitting the tail into pieces, which is wrong depending on whether each piece is in a separate register or in memory.
> 
> Why do you think so? Do you have an example where the new patch fails?

No, I don't know that it fails.  But neither do I know that it is OK, so you'll at least need to get someone else to review the patch.

Dale has dealt with this code quite a lot and last time we put this patch in, he objected that it might be unsafe by causing accesses past the end of an aggregate.  At the time, I replied by citing a comment in the x86-64 code suggesting that gcc does the same thing, but after looking at it more closely, I think that comment was referring to a slightly different case.

> 
> The byval argument was introduced to handle cases in the ELF x86_64
> abi where it is not possible to map how a struct is passed to an
> equivalent way of passing primitive types. It also had some additional
> benefits in the end.

Well, I don't know the history, but "byval" is essentially the default for passing structures on both ppc and x86-32.  Without knowing otherwise, I'm inclined to follow the same approach for ARM.

> 
> Do you have a case in the ARM ABI where we cannot map a struct passing
> to an equivalent way of passing primitive types? If so, I can try to
> implement byval for ARM, but it will take me some time to get to it.
> If not, I would suggest doing the quick fix first.

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.  



More information about the llvm-commits mailing list