[LLVMdev] Suggestion: Support union types in IR

Eli Friedman eli.friedman at gmail.com
Tue Dec 30 13:20:29 PST 2008


On Tue, Dec 30, 2008 at 12:41 PM, Talin <viridia at gmail.com> wrote:
> I've been thinking about how to represent unions or "disjoint types" in LLVM
> IR.

This has been rejected in the past due to insufficient utility:
bitcasts have worked perfectly fine in the past...

> At the moment, the only way I know to achieve this right now is to
> create a struct that is as large as the largest type in the union and then
> bitcast it to access the fields contained within. However, that requires
> that the frontend know the sizes of all of the various low-level types (the
> "size_t" problem, which has been discussed before), otherwise you get
> problems trying to mix pointer and non-pointer types.

I thought we had a reasonable solution to the sizeof problem: the
getelementptr trick.  Why isn't that usable here?

-Eli



More information about the llvm-dev mailing list