[opaque pointer type] Add textual IR support for explicit type parameter for global...
[oota-llvm.git] / test / Transforms / LowerBitSets / function.ll
1 ; RUN: opt -S -lowerbitsets < %s | FileCheck %s
2
3 ; Tests that we correctly create a jump table for bitsets containing 2 or more
4 ; functions.
5
6 target triple = "x86_64-unknown-linux-gnu"
7 target datalayout = "e-p:64:64"
8
9 ; CHECK: @[[JT:.*]] = private constant [2 x <{ i8, i32, i8, i8, i8 }>] [<{ i8, i32, i8, i8, i8 }> <{ i8 -23, i32 trunc (i64 sub (i64 sub (i64 ptrtoint (void ()* @[[FNAME:.*]] to i64), i64 ptrtoint ([2 x <{ i8, i32, i8, i8, i8 }>]* @[[JT]] to i64)), i64 5) to i32), i8 -52, i8 -52, i8 -52 }>, <{ i8, i32, i8, i8, i8 }> <{ i8 -23, i32 trunc (i64 sub (i64 sub (i64 ptrtoint (void ()* @[[GNAME:.*]] to i64), i64 ptrtoint ([2 x <{ i8, i32, i8, i8, i8 }>]* @[[JT]] to i64)), i64 13) to i32), i8 -52, i8 -52, i8 -52 }>], section ".text"
10
11 ; CHECK: @f = alias void (), bitcast ([2 x <{ i8, i32, i8, i8, i8 }>]* @[[JT]] to void ()*)
12 ; CHECK: @g = alias void (), bitcast (<{ i8, i32, i8, i8, i8 }>* getelementptr inbounds ([2 x <{ i8, i32, i8, i8, i8 }>], [2 x <{ i8, i32, i8, i8, i8 }>]* @[[JT]], i64 0, i64 1) to void ()*)
13
14 ; CHECK: define private void @[[FNAME]]() {
15 define void @f() {
16   ret void
17 }
18
19 ; CHECK: define private void @[[GNAME]]() {
20 define void @g() {
21   ret void
22 }
23
24 !0 = !{!"bitset1", void ()* @f, i32 0}
25 !1 = !{!"bitset1", void ()* @g, i32 0}
26
27 !llvm.bitsets = !{ !0, !1 }
28
29 declare i1 @llvm.bitset.test(i8* %ptr, metadata %bitset) nounwind readnone
30
31 define i1 @foo(i8* %p) {
32   ; CHECK: sub i64 {{.*}}, ptrtoint ([2 x <{ i8, i32, i8, i8, i8 }>]* @[[JT]] to i64)
33   %x = call i1 @llvm.bitset.test(i8* %p, metadata !"bitset1")
34   ret i1 %x
35 }