[LLVMdev] named types with self-references

Jianzhou Zhao jianzhou at seas.upenn.edu
Thu Nov 11 08:45:48 PST 2010


Hello,

Can I define a named type ?   %rt = {%rt}
llvm-as can parse this definition without errors.

JIT executes '%0 = alloca %rt' as allocating a memory with size 0.
Because the llvm::TargetData::getTypeAllocSize accually returns 0 in
this case. The function that calculates %rt's size is by the
TargetData::getStructLayout, which calculates the a layout of %rt. It
can only returns 0 when the element type %rt is not defined yet, since
the result is infinite otherwise.

Is %rt = {%rt} still a valid or useful type for LLVM IR? %rt = {%rt*},
{ \2 }* or even \1* are definitely good types to represent recursive
data types. In which case do we need %rt = {%rt}?

Thanks
-- 
Jianzhou



More information about the llvm-dev mailing list