[LLVMdev] Opaque Undef Types?

Chris Lattner sabre at nondot.org
Fri May 13 08:32:10 PDT 2005


On Fri, 13 May 2005, Reid Spencer wrote:
> I'm looking at and running:
> test/Regression/Assembler/2005-05-05-OpaqueUndefValues.ll
>
> which says:
> ; RUN: llvm-as < %s | llvm-dis | llvm-as
>
> %t = type opaque
> %x = global %t undef
>
> Why is this valid? Shouldn't the assembler reject it (it doesn't)? How
> can a global variable be defined as opaque? What's it size?

It has no size yet.

> Does this just indicate that %x is some "unknown undefined" global which
> will be resolved when linking?

undefined == external, so no.

> If so, the CBE will choke (abort) on it, as does my XPLBE. Should I fix
> this? How? Just declare it as a "char" or something? Won't that confuse
> the linker?

The LLVM type system is more general than the C type system in a couple of 
ways.  For example, it also allows definitions like "{ opaque, int }". 
This is fine as long as the type is resolved before codegen (e.g. at 
link-time), because code generators obviously like to have known offsets 
to elements in the struct.

Like you said, this sort of thing isn't supported by any of the other code 
generators, so I don't know why yours would be any different in this way.

-Chris

-- 
http://nondot.org/sabre/
http://llvm.cs.uiuc.edu/




More information about the llvm-dev mailing list