[LLVMdev] [LLVM, llvm-link] Opaque types.

Chris Lattner clattner at apple.com
Tue Dec 20 12:49:50 PST 2011


On Dec 20, 2011, at 12:11 PM, Stepan Dyatkovskiy wrote:

> Is it legal to substitute non struct type instead of opaque type?
> 
> For example:
> ; 1.ll
> declare void @F(i32*)
> 
> ; 2.ll
> %T1 = type opaque
> declare void @F(%T1*)
> 
> Is it normal to replace T1 with i32 here?

Yes, the linker will do this, because it is forced to break type safety to link up the functions.

> If yes. Will the next types are isomorphic?:
> 
> %T1 = type opaque
> { i32, %T1* }
> { i32, i32* }

No.  opaque types are instances of struct types and are uniqued by name.  i32 is not a struct type.   These two types are also not isomorphic:

> %T1 = type opaque
> %T2 = type opaque
> { i32, %T1* }
> { i32, %T2* }


-Chris



More information about the llvm-dev mailing list