diff options
Diffstat (limited to 'llvm/test')
-rw-r--r-- | llvm/test/Transforms/LowerBitSets/function-ext.ll | 22 | ||||
-rw-r--r-- | llvm/test/Transforms/LowerBitSets/function.ll | 35 | ||||
-rw-r--r-- | llvm/test/Transforms/LowerBitSets/nonstring.ll | 34 | ||||
-rw-r--r-- | llvm/test/Transforms/LowerBitSets/simple.ll | 8 |
4 files changed, 95 insertions, 4 deletions
diff --git a/llvm/test/Transforms/LowerBitSets/function-ext.ll b/llvm/test/Transforms/LowerBitSets/function-ext.ll new file mode 100644 index 00000000000..2a83bef2f07 --- /dev/null +++ b/llvm/test/Transforms/LowerBitSets/function-ext.ll @@ -0,0 +1,22 @@ +; RUN: opt -S -lowerbitsets < %s | FileCheck %s + +; Tests that we correctly handle external references, including the case where +; all functions in a bitset are external references. + +target triple = "x86_64-unknown-linux-gnu" + +declare void @foo() + +; CHECK: @[[JT:.*]] = private constant [1 x <{ i8, i32, i8, i8, i8 }>] [<{ i8, i32, i8, i8, i8 }> <{ i8 -23, i32 trunc (i64 sub (i64 sub (i64 ptrtoint (void ()* @foo to i64), i64 ptrtoint ([1 x <{ i8, i32, i8, i8, i8 }>]* @[[JT]] to i64)), i64 5) to i32), i8 -52, i8 -52, i8 -52 }>], section ".text" + +define i1 @bar(i8* %ptr) { + ; CHECK: icmp eq i64 {{.*}}, ptrtoint ([1 x <{ i8, i32, i8, i8, i8 }>]* @[[JT]] to i64) + %p = call i1 @llvm.bitset.test(i8* %ptr, metadata !"void") + ret i1 %p +} + +declare i1 @llvm.bitset.test(i8* %ptr, metadata %bitset) nounwind readnone + +!0 = !{!"void", void ()* @foo, i64 0} + +!llvm.bitsets = !{!0} diff --git a/llvm/test/Transforms/LowerBitSets/function.ll b/llvm/test/Transforms/LowerBitSets/function.ll new file mode 100644 index 00000000000..0aa947e5a2d --- /dev/null +++ b/llvm/test/Transforms/LowerBitSets/function.ll @@ -0,0 +1,35 @@ +; RUN: opt -S -lowerbitsets < %s | FileCheck %s + +; Tests that we correctly create a jump table for bitsets containing 2 or more +; functions. + +target triple = "x86_64-unknown-linux-gnu" +target datalayout = "e-p:64:64" + +; 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" + +; CHECK: @f = alias bitcast ([2 x <{ i8, i32, i8, i8, i8 }>]* @[[JT]] to void ()*) +; CHECK: @g = alias 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 ()*) + +; CHECK: define private void @[[FNAME]]() { +define void @f() { + ret void +} + +; CHECK: define private void @[[GNAME]]() { +define void @g() { + ret void +} + +!0 = !{!"bitset1", void ()* @f, i32 0} +!1 = !{!"bitset1", void ()* @g, i32 0} + +!llvm.bitsets = !{ !0, !1 } + +declare i1 @llvm.bitset.test(i8* %ptr, metadata %bitset) nounwind readnone + +define i1 @foo(i8* %p) { + ; CHECK: sub i64 {{.*}}, ptrtoint ([2 x <{ i8, i32, i8, i8, i8 }>]* @[[JT]] to i64) + %x = call i1 @llvm.bitset.test(i8* %p, metadata !"bitset1") + ret i1 %x +} diff --git a/llvm/test/Transforms/LowerBitSets/nonstring.ll b/llvm/test/Transforms/LowerBitSets/nonstring.ll new file mode 100644 index 00000000000..0d655da3bb0 --- /dev/null +++ b/llvm/test/Transforms/LowerBitSets/nonstring.ll @@ -0,0 +1,34 @@ +; RUN: opt -S -lowerbitsets < %s | FileCheck %s + +; Tests that non-string metadata nodes may be used as bitset identifiers. + +target datalayout = "e-p:32:32" + +; CHECK: @[[BNAME:.*]] = private constant { [2 x i32] } +; CHECK: @[[ANAME:.*]] = private constant { i32 } + +@a = constant i32 1 +@b = constant [2 x i32] [i32 2, i32 3] + +!0 = !{!2, i32* @a, i32 0} +!1 = !{!3, [2 x i32]* @b, i32 0} +!2 = distinct !{} +!3 = distinct !{} + +!llvm.bitsets = !{ !0, !1 } + +declare i1 @llvm.bitset.test(i8* %ptr, metadata %bitset) nounwind readnone + +; CHECK-LABEL: @foo +define i1 @foo(i8* %p) { + ; CHECK: icmp eq i32 {{.*}}, ptrtoint ({ i32 }* @[[ANAME]] to i32) + %x = call i1 @llvm.bitset.test(i8* %p, metadata !2) + ret i1 %x +} + +; CHECK-LABEL: @bar +define i1 @bar(i8* %p) { + ; CHECK: icmp eq i32 {{.*}}, ptrtoint ({ [2 x i32] }* @[[BNAME]] to i32) + %x = call i1 @llvm.bitset.test(i8* %p, metadata !3) + ret i1 %x +} diff --git a/llvm/test/Transforms/LowerBitSets/simple.ll b/llvm/test/Transforms/LowerBitSets/simple.ll index 0fcdf0b36d6..df2ccf98786 100644 --- a/llvm/test/Transforms/LowerBitSets/simple.ll +++ b/llvm/test/Transforms/LowerBitSets/simple.ll @@ -6,8 +6,8 @@ target datalayout = "e-p:32:32" ; CHECK: [[G:@[^ ]*]] = private constant { i32, [0 x i8], [63 x i32], [4 x i8], i32, [0 x i8], [2 x i32] } { i32 1, [0 x i8] zeroinitializer, [63 x i32] zeroinitializer, [4 x i8] zeroinitializer, i32 3, [0 x i8] zeroinitializer, [2 x i32] [i32 4, i32 5] } @a = constant i32 1 -@b = constant [63 x i32] zeroinitializer -@c = constant i32 3 +@b = hidden constant [63 x i32] zeroinitializer +@c = protected constant i32 3 @d = constant [2 x i32] [i32 4, i32 5] ; CHECK: [[BA:@[^ ]*]] = private constant [68 x i8] c"\03\01\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\01" @@ -43,8 +43,8 @@ target datalayout = "e-p:32:32" ; CHECK: @bits_use.{{[0-9]*}} = private alias i8* @bits{{[0-9]*}} ; CHECK: @a = alias getelementptr inbounds ({ i32, [0 x i8], [63 x i32], [4 x i8], i32, [0 x i8], [2 x i32] }, { i32, [0 x i8], [63 x i32], [4 x i8], i32, [0 x i8], [2 x i32] }* [[G]], i32 0, i32 0) -; CHECK: @b = alias getelementptr inbounds ({ i32, [0 x i8], [63 x i32], [4 x i8], i32, [0 x i8], [2 x i32] }, { i32, [0 x i8], [63 x i32], [4 x i8], i32, [0 x i8], [2 x i32] }* [[G]], i32 0, i32 2) -; CHECK: @c = alias getelementptr inbounds ({ i32, [0 x i8], [63 x i32], [4 x i8], i32, [0 x i8], [2 x i32] }, { i32, [0 x i8], [63 x i32], [4 x i8], i32, [0 x i8], [2 x i32] }* [[G]], i32 0, i32 4) +; CHECK: @b = hidden alias getelementptr inbounds ({ i32, [0 x i8], [63 x i32], [4 x i8], i32, [0 x i8], [2 x i32] }, { i32, [0 x i8], [63 x i32], [4 x i8], i32, [0 x i8], [2 x i32] }* [[G]], i32 0, i32 2) +; CHECK: @c = protected alias getelementptr inbounds ({ i32, [0 x i8], [63 x i32], [4 x i8], i32, [0 x i8], [2 x i32] }, { i32, [0 x i8], [63 x i32], [4 x i8], i32, [0 x i8], [2 x i32] }* [[G]], i32 0, i32 4) ; CHECK: @d = alias getelementptr inbounds ({ i32, [0 x i8], [63 x i32], [4 x i8], i32, [0 x i8], [2 x i32] }, { i32, [0 x i8], [63 x i32], [4 x i8], i32, [0 x i8], [2 x i32] }* [[G]], i32 0, i32 6) ; CHECK-DARWIN: @aptr = constant i32* getelementptr inbounds ({ i32, [0 x i8], [63 x i32], [4 x i8], i32, [0 x i8], [2 x i32] }, { i32, [0 x i8], [63 x i32], [4 x i8], i32, [0 x i8], [2 x i32] }* [[G:@[^ ]*]], i32 0, i32 0) |