[LLVMdev] User defined types in LLVM-IR

Duncan Sands baldrick at free.fr
Sat Apr 2 00:12:40 PDT 2011


Hi Arushi,

> LLVM front end is taking a user defined type of
>
> [21 x { i32, i32, i32, [8 x i32] }]
>
> and converting it to the structurally equivalent type
>
> { { i32, i32, i32, [8 x i32] }, { i32, i32, i32, [8 x i32] }, { i32, i32, i32,
> [8 x i32] }, { i32, i32, i32, [8 x i32] }, { i32, i32, i32, [8 x i32] }, { i32,
> i32, i32, [8 x i32] }, { i32, i32, i32, [8 x i32] }, { i32, i32, i32, [8 x i32]
> }, { i32, i32, i32, [32 x i8] }, { i32, i32, i32, [32 x i8] }, { i32, i32, i32,
> [32 x i8] }, { i32, i32, i32, [32 x i8] }, { i32, i32, i32, [32 x i8] }, { i32,
> i32, i32, [32 x i8] }, { i32, i32, i32, [8 x i32] }, { i32, i32, i32, [8 x i32]
> }, { i32, i32, i32, [8 x i32] }, { i32, i32, i32, [8 x i32] }, { i32, i32, i32,
> [8 x i32] }, { i32, i32, i32, [8 x i32] }, { i32, i32, i32, [32 x i8] } }
>
> Is there any utility function, that given these two types can say they are
> structurally equivalent? Or not, for some other 2 types?

I don't think so.  But why does it matter that clang used a struct rather
than an array?

> If I were to write such a function, are there any special properties that need
> to be checked?

The type alloc size (see TargetData) and the alignment of the two types should
be the same.  Otherwise it doesn't matter much what you do for aggregate types,
though you tend to get better code if fields start and end at the same spot as
in the original user defined type.

Ciao, Duncan.



More information about the llvm-dev mailing list