blob: 2a83bef2f074851e5170dc8d3fda6b88f690cbc9 [file] [log] [blame]
Peter Collingbourne8d24ae92015-09-08 22:49:35 +00001; RUN: opt -S -lowerbitsets < %s | FileCheck %s
2
3; Tests that we correctly handle external references, including the case where
4; all functions in a bitset are external references.
5
6target triple = "x86_64-unknown-linux-gnu"
7
8declare void @foo()
9
10; 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"
11
12define i1 @bar(i8* %ptr) {
13 ; CHECK: icmp eq i64 {{.*}}, ptrtoint ([1 x <{ i8, i32, i8, i8, i8 }>]* @[[JT]] to i64)
14 %p = call i1 @llvm.bitset.test(i8* %ptr, metadata !"void")
15 ret i1 %p
16}
17
18declare i1 @llvm.bitset.test(i8* %ptr, metadata %bitset) nounwind readnone
19
20!0 = !{!"void", void ()* @foo, i64 0}
21
22!llvm.bitsets = !{!0}