[LLVMdev] Cannot interchange "literal" and "identified" structs

NAKAMURA Takumi geek4civic at gmail.com
Sun Dec 30 15:19:38 PST 2012


Justin,

http://llvm.org/docs/LangRef.html#structure-type
"Identified types can be recursive, can be opaqued, and are never uniqued."
Do you think it would be less descriptive?

"Identified type, aka named llvm::StructType, is never uniqued against
other identified types nor literal types, aka unnamed StructType(s)."
?

See also; http://blog.llvm.org/2011/11/llvm-30-type-system-rewrite.html

...Takumi

2012/12/30 Justin Holewinski <justin.holewinski at gmail.com>:
> With primitive types, I can interchange literal usage and type aliases in
> IR:
>
> %mytype = type i32
>
> define void @foo(%mytype* %ptr) {
>   %t1 = load %mytype* %ptr
>   store i32 %t1, i32* %ptr
>   ret void
> }
>
> But for structs, I cannot:
>
> %mytype = type { i32, i32 }
>
> define void @foo(%mytype* %ptr) {
>   %t1 = load %mytype* %ptr
>   store { i32, i32 } %t1, { i32, i32 }* %ptr
>   ret void
> }
>
> bin/llvm-as: alias2.ll:6:22: error: '%t1' defined with type '%mytype = type
> { i32, i32 }'
>   store { i32, i32 } %t1, { i32, i32 }* %ptr
>
> I don't see anything in the language reference manual that disallows such
> usage, as the literal struct type and %mytype are equivalent.  Am I missing
> something here, or is this just a bug in the assembly parser?
>
> --
>
> Thanks,
>
> Justin Holewinski
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>



More information about the llvm-dev mailing list