User defined types in LLVM-IR

Hi all,

Given a LLVM bitcode file, is there any way of knowing which type declarations actually came from the user code and what transformations were made by the front end.

Thanks,
Arushi

Hi Arushi,

Given a LLVM bitcode file, is there any way of knowing which type declarations
actually came from the user code and what transformations were made by the front
end.

not really. However debug info may give you some of the information you are
looking for.

Ciao, Duncan.

Hi,

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?

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

Thanks,
Arushi

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.