[cfe-commits] [PATCH] CodeGen support for transparent_union

Stefan Kristiansson stefan.kristiansson at saunalahti.fi
Sun Jul 8 20:28:59 PDT 2012


This is a follow-up to the message I sent to cfe-dev about
unexpected behaviour on transparent unions [1].

As I mentioned there, currently when unions marked with the transparent_union
attribute are used as function arguments, the declared function gets called
with the union instead of the calling convention of the first field in
the transparent union as is required by the description [2].

Looking at the commit log, most of the current implementation of the
transparent_union attribute support origins from r70419, which actually
mentions the lack of proper CodeGen support [3].

Attached is a patch that tries to improve the situation by converting the
type to the first field of the union, but there are a couple of things I am
not completely satisfied with, so feedback on this patch is most welcome.
The thing that bugs me most is the conversion in classifyArgument in
lib/CodeGen/TargetInfo.cpp. Since this is ABI specific, every ABI
has to do the conversion, which seems sub-optimal to me.


[1] http://lists.cs.uiuc.edu/pipermail/cfe-dev/2012-July/022672.html
[2] http://gcc.gnu.org/onlinedocs/gcc/Type-Attributes.html
[3] http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20090427/016496.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: CodeGen_support_for_transparent_union.patch
Type: application/octet-stream
Size: 5097 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120709/80924aa9/attachment.obj>

More information about the cfe-commits mailing list