[LLVMdev] alignment issue, getting corrupt double values

edA-qa mort-ora-y eda-qa at disemia.com
Mon Dec 31 10:58:51 PST 2012


On 31/12/12 19:47, Joe Groff wrote:
>  I think most backends treat struct return by value as returning
> multiple values in registers; for instance, {i32, i64} returns into
> {EAX, RDX} on x86-64. Since most architectures don't specify any more
> than two return registers and you can't really "spill" a return value,
> weird poorly-tested things probably happen if you try to return a struct
> with more elements than the backend has return registers for. You could
> try returning larger structs indirectly using an sret pointer like Clang
> does.

I do pass the return as the first parameter pointer now. I didn't know
about sret, I guess I should mark it is as such (does it help
optimization then?)

I also think it is kind of dangerous that LLVM silently accepts returns
of larger structures and then produces invalid code.  Note that it does
actually pass by pointer if the backend can't return it directly, just
in certain cases it fails to produce correct code.

-- 
edA-qa mort-ora-y
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Sign: Please digitally sign your emails.
Encrypt: I'm also happy to receive encrypted mail.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 261 bytes
Desc: OpenPGP digital signature
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20121231/6c238789/attachment.sig>


More information about the llvm-dev mailing list