[LLVMdev] Union types

Renato Golin rengolin at systemcall.org
Mon Mar 29 05:15:30 PDT 2010


Hi All,

I've noticed the union type in the language manual [1] but it seems
it's not used too much.

According to the manual, the code:
union {
  int a;
  double b;
} a;

Could be compiled to:
%union.anon =  type union { i32, double }

@a = common global %union.anon zeroinitializer, align 8 ;
<%union.anon*> [#uses=0]

But when I try to assemble it, I get:

$ llvm-as union.ll
llvm-as: Constants.cpp:67: static llvm::Constant*
llvm::Constant::getNullValue(const llvm::Type*): Assertion `!"Cannot
create a null constant of that type!"' failed.

The comment just above that line is:
default:
   // Function, Label, or Opaque type?

Which implies no one was expecting a UnionType there...

Also, if I generate the object code directly, llc fails too...

Is there any plan to implement the union type? The work-around is quite ugly...


cheers,
--renato

http://systemcall.org/

[1] http://llvm.org/docs/LangRef.html#t_union



More information about the llvm-dev mailing list