defining types structurally equivalent to a recursive type

Hi all,

http://www.llvm.org/docs/ProgrammersManual.html#BuildRecType suggests
us to define recursive types via opaque and refine. Since LLVM has
structural types, %rt = type { %rt* } and %rt1 = type { %rt* } should
be same structurally. I tested the following code,

%rt = type { %rt* }
%rt1 = type { %rt* }

define i32 @main() nounwind {
entry:
  %0 = alloca %rt ; <%rt*> [#uses=1]
  %1 = alloca %rt ; <%rt*> [#uses=1]
  %2 = icmp eq %rt* %0, %1 ; <i1> [#uses=0]
  ret i32 0
}

In the code, LLVM unifies %rt and %rt1 to be same, and picks %rt to
represent them. If I define %rt %rt1 manually, can I first define %rt
by opaque and refine, and then define %rt1 as normal structures ---
defining %rt1 as a 'concreate' structure by Struct::Get with the
element type %rt, since %rt1 is not a recursive type 'syntatically'.
But I am wondering if I need PATypeHolder to protect %rt1. Will %rt1
be deleted if LLVM finds it is same to %rt?

Thanks.

Hi all,

http://www.llvm.org/docs/ProgrammersManual.html#BuildRecType suggests
us to define recursive types via opaque and refine. Since LLVM has
structural types, %rt = type { %rt* } and %rt1 = type { %rt* } should
be same structurally. I tested the following code,

%rt = type { %rt* }
%rt1 = type { %rt* }

define i32 @main() nounwind {
entry:
%0 = alloca %rt ; <%rt*> [#uses=1]
%1 = alloca %rt ; <%rt*> [#uses=1]
%2 = icmp eq %rt* %0, %1 ; <i1> [#uses=0]
ret i32 0
}

Sorry, my orginal test code is:

%rt = type { %rt* }
%rt1 = type { %rt* }

define i32 @main() nounwind {
entry:
  %0 = alloca %rt
  %1 = alloca %rt1
  %2 = icmp eq %rt* %0, %1
  ret i32 0
}

After llvm-as, llvm-dis, LLVM automatically renames all %rt1 to be
%rt. The 'icmp' is to test if LLVM takes them to be same, since icmp
requires operands be of same type.

Hi all,

http://www.llvm.org/docs/ProgrammersManual.html#BuildRecType suggests
us to define recursive types via opaque and refine. Since LLVM has
structural types, %rt = type { %rt* } and %rt1 = type { %rt* } should
be same structurally. I tested the following code,

%rt = type { %rt* }
%rt1 = type { %rt* }

define i32 @main() nounwind {
entry:
%0 = alloca %rt ; <%rt*> [#uses=1]
%1 = alloca %rt ; <%rt*> [#uses=1]
%2 = icmp eq %rt* %0, %1 ; <i1> [#uses=0]
ret i32 0
}

Sorry, my orginal test code is:

%rt = type { %rt* }
%rt1 = type { %rt* }

define i32 @main() nounwind {
entry:
%0 = alloca %rt
%1 = alloca %rt1
%2 = icmp eq %rt* %0, %1
ret i32 0
}

After llvm-as, llvm-dis, LLVM automatically renames all %rt1 to be
%rt. The 'icmp' is to test if LLVM takes them to be same, since icmp
requires operands be of same type.

Yep, that's correct behavior.

-Chris