1 ; RUN: opt -S -lowertypetests < %s | FileCheck %s
3 target datalayout = "e-p:32:32"
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
9 !0 = !{i32 0, !"typeid1"}
10 !1 = !{i32 0, !"typeid2"}
11 !2 = !{i32 0, !"typeid3"}
13 declare i1 @llvm.type.test(i8* %ptr, metadata %bitset) nounwind readnone
15 ; CHECK: @foo(i8* [[A0:%[^ ]*]])
16 define 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]]
24 ; CHECK: @bar(i8* [[B0:%[^ ]*]])
25 define 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]]
34 define i1 @x(i8* %p) {
35 %x = call i1 @llvm.type.test(i8* %p, metadata !"typeid1")