diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2015-09-08 21:57:45 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2015-09-08 21:57:45 +0000 |
commit | c634ed0b1a421e5458cd698a7fcd89ded0ab6d2f (patch) | |
tree | cfc38178d294001efccd24f743daf38638723d8a /llvm/test/Transforms/LowerBitSets/function-ext.ll | |
parent | 18608a0a55856e1788e7c9ec1c1841c5cb455ed4 (diff) | |
download | bcm5719-llvm-c634ed0b1a421e5458cd698a7fcd89ded0ab6d2f.tar.gz bcm5719-llvm-c634ed0b1a421e5458cd698a7fcd89ded0ab6d2f.zip |
LowerBitSets: Extend pass to support functions as bitset members.
This change extends the bitset lowering pass to support bitsets that may
contain either functions or global variables. A function bitset is lowered to
a jump table that is laid out before one of the functions in the bitset.
Also add support for non-string bitset identifier names. This allows for
distinct metadata nodes to stand in for names with internal linkage,
as done in D11857.
Differential Revision: http://reviews.llvm.org/D11856
llvm-svn: 247080
Diffstat (limited to 'llvm/test/Transforms/LowerBitSets/function-ext.ll')
-rw-r--r-- | llvm/test/Transforms/LowerBitSets/function-ext.ll | 22 |
1 files changed, 22 insertions, 0 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} |