1; RUN: opt -S -lowertypetests < %s | FileCheck %s 2 3target datalayout = "e-p:32:32" 4 5; CHECK: [[G:@[^ ]*]] = private constant { i32, [0 x i8], i32 } 6@a = constant i32 1, !type !0, !type !1 7@b = constant i32 2, !type !0, !type !2 8 9!0 = !{i32 0, !"typeid1"} 10!1 = !{i32 0, !"typeid2"} 11!2 = !{i32 0, !"typeid3"} 12 13declare i1 @llvm.type.test(i8* %ptr, metadata %bitset) nounwind readnone 14 15; CHECK: @foo(i8* [[A0:%[^ ]*]]) 16define i1 @foo(i8* %p) { 17 ; CHECK: [[R0:%[^ ]*]] = ptrtoint i8* [[A0]] to i32 18 ; CHECK: [[R1:%[^ ]*]] = icmp eq i32 [[R0]], ptrtoint ({ i32, [0 x i8], i32 }* [[G]] to i32) 19 %x = call i1 @llvm.type.test(i8* %p, metadata !"typeid2") 20 ; CHECK: ret i1 [[R1]] 21 ret i1 %x 22} 23 24; CHECK: @bar(i8* [[B0:%[^ ]*]]) 25define i1 @bar(i8* %p) { 26 ; CHECK: [[S0:%[^ ]*]] = ptrtoint i8* [[B0]] to i32 27 ; CHECK: [[S1:%[^ ]*]] = icmp eq i32 [[S0]], ptrtoint (i8* getelementptr (i8, i8* bitcast ({ i32, [0 x i8], i32 }* [[G]] to i8*), i32 4) to i32) 28 %x = call i1 @llvm.type.test(i8* %p, metadata !"typeid3") 29 ; CHECK: ret i1 [[S1]] 30 ret i1 %x 31} 32 33; CHECK: @x( 34define i1 @x(i8* %p) { 35 %x = call i1 @llvm.type.test(i8* %p, metadata !"typeid1") 36 ret i1 %x 37} 38