[LLVMdev] Union type, is it really used or necessary?

Renato Golin rengolin at systemcall.org
Wed Sep 8 01:47:53 PDT 2010


On 8 September 2010 00:31, Erik de Castro Lopo <mle+cl at mega-nerd.com> wrote:
> 'It needs work' and 'it was broken' doesn't really give me an
> idea of what specifically is required.

Search for "union" in the list and you'll find lots of problems and
places to fix.

I remember that Constant doesn't support zero-initialize for unions,
so even before codegen. Also, there was no support at all in the
generic codegen, nor target specific (AFAIK), which is a major factor
for unions, since type sizes, alignment and ABIs play an important
role in how you'll represent unions in code. Also, given it's dubious
status, I doubt there is anything related to that in MC.

I agree that the decision to remove it could be taken a bit less
lightly (maybe asking around first), but if you don't monitor the list
nor the change log (which said it would probably be removed), there
isn't much more to do.

If you want to support unions, you'll have to revert the commit,
extend support in IR (ex. implementing zero-initialize), and implement
the basic support in MC with at least one target (x86?). Even if you
don't use union types for generating code, people would come and think
there is support and report bugs on something that has zero
maintenance. In the end, if you're not willing to support "unions" as
a whole feature, it'll end up the same way as the previous
implementation.

I am one of the advocates we must have unions and it's up to the
codegen to figure out (based on data layout + architecture + whatever
else) what to do with it. But I also have to be realist and accept the
fact that if I can't spare the time to implement it decently, I should
wait until someone does (I do hope that's you!). ;)

-- 
cheers,
--renato

http://systemcall.org/

Reclaim your digital rights, eliminate DRM, learn more at
http://www.defectivebydesign.org/what_is_drm



More information about the llvm-dev mailing list