1 ; RUN: opt -S -lowertypetests -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck --check-prefixes=CHECK,X64 %s
2 ; RUN: opt -S -lowertypetests -mtriple=wasm32-unknown-unknown < %s | FileCheck --check-prefixes=CHECK,WASM32 %s
4 ; Tests that we correctly handle external references, including the case where
5 ; all functions in a bitset are external references.
7 ; WASM32: private constant [0 x i8] zeroinitializer
9 ; WASM32: declare !type !{{[0-9]+}} !wasm.index !{{[0-9]+}} void @foo1()
10 declare !type !0 void @foo1()
11 ; WASM32: declare !type !{{[0-9]+}} void @foo2()
12 declare !type !1 void @foo2()
15 define i1 @bar(i8* %ptr) {
16 ; CHECK: %[[ICMP:[0-9]+]] = icmp eq
17 ; CHECK: ret i1 %[[ICMP]]
18 %p = call i1 @llvm.type.test(i8* %ptr, metadata !"type1")
23 define i1 @baz(i8* %ptr) {
25 %p = call i1 @llvm.type.test(i8* %ptr, metadata !"type2")
29 ; CHECK-LABEL: @addrtaken
30 define void()* @addrtaken() {
31 ; X64: ret void ()* @[[JT:.*]]
35 declare i1 @llvm.type.test(i8* %ptr, metadata %bitset) nounwind readnone
37 !0 = !{i64 0, !"type1"}
38 !1 = !{i64 0, !"type2"}
40 ; X64: define private void @[[JT]]() #{{.*}} align {{.*}} {
41 ; X64: call void asm sideeffect "jmp ${0:c}@plt\0Aint3\0Aint3\0Aint3\0A", "s"(void ()* @foo1)