]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/Transforms/LowerTypeTests/function.ll
Vendor import of llvm trunk r291274:
[FreeBSD/FreeBSD.git] / test / Transforms / LowerTypeTests / function.ll
1 ; RUN: opt -S -lowertypetests -mtriple=i686-unknown-linux-gnu < %s | FileCheck --check-prefixes=X86,X86-LINUX,NATIVE %s
2 ; RUN: opt -S -lowertypetests -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck --check-prefixes=X86,X86-LINUX,NATIVE %s
3 ; RUN: opt -S -lowertypetests -mtriple=i686-pc-win32 < %s | FileCheck --check-prefixes=X86,X86-WIN32,NATIVE %s
4 ; RUN: opt -S -lowertypetests -mtriple=x86_64-pc-win32 < %s | FileCheck --check-prefixes=X86,X86-WIN32,NATIVE %s
5 ; RUN: opt -S -lowertypetests -mtriple=arm-unknown-linux-gnu < %s | FileCheck --check-prefixes=ARM,NATIVE %s
6 ; RUN: opt -S -lowertypetests -mtriple=thumb-unknown-linux-gnu < %s | FileCheck --check-prefixes=THUMB,NATIVE %s
7 ; RUN: opt -S -lowertypetests -mtriple=aarch64-unknown-linux-gnu < %s | FileCheck --check-prefixes=ARM,NATIVE %s
8 ; RUN: opt -S -lowertypetests -mtriple=wasm32-unknown-unknown < %s | FileCheck --check-prefix=WASM32 %s
9
10 ; Tests that we correctly handle bitsets containing 2 or more functions.
11
12 target datalayout = "e-p:64:64"
13
14
15 ; NATIVE: @0 = private unnamed_addr constant [2 x void (...)*] [void (...)* bitcast (void ()* @f to void (...)*), void (...)* bitcast (void ()* @g to void (...)*)], align 16
16 @0 = private unnamed_addr constant [2 x void (...)*] [void (...)* bitcast (void ()* @f to void (...)*), void (...)* bitcast (void ()* @g to void (...)*)], align 16
17
18 ; NATIVE: private constant [0 x i8] zeroinitializer
19 ; WASM32: private constant [0 x i8] zeroinitializer
20
21 ; NATIVE: @f = alias void (), void ()* @[[JT:.*]]
22
23 ; X86: @g = internal alias void (), bitcast ([8 x i8]* getelementptr inbounds ([2 x [8 x i8]], [2 x [8 x i8]]* bitcast (void ()* @[[JT]] to [2 x [8 x i8]]*), i64 0, i64 1) to void ()*)
24 ; ARM: @g = internal alias void (), bitcast ([4 x i8]* getelementptr inbounds ([2 x [4 x i8]], [2 x [4 x i8]]* bitcast (void ()* @[[JT]] to [2 x [4 x i8]]*), i64 0, i64 1) to void ()*)
25 ; THUMB: @g = internal alias void (), bitcast ([4 x i8]* getelementptr inbounds ([2 x [4 x i8]], [2 x [4 x i8]]* bitcast (void ()* @[[JT]] to [2 x [4 x i8]]*), i64 0, i64 1) to void ()*)
26
27 ; NATIVE: define internal void @f.cfi()
28 ; WASM32: define void @f() !type !{{[0-9]+}} !wasm.index ![[I0:[0-9]+]]
29 define void @f() !type !0 {
30   ret void
31 }
32
33 ; NATIVE: define internal void @g.cfi()
34 ; WASM32: define internal void @g() !type !{{[0-9]+}} !wasm.index ![[I1:[0-9]+]]
35 define internal void @g() !type !0 {
36   ret void
37 }
38
39 !0 = !{i32 0, !"typeid1"}
40
41 declare i1 @llvm.type.test(i8* %ptr, metadata %bitset) nounwind readnone
42
43 define i1 @foo(i8* %p) {
44   ; NATIVE: sub i64 {{.*}}, ptrtoint (void ()* @[[JT]] to i64)
45   ; WASM32: sub i64 {{.*}}, ptrtoint (i8* getelementptr (i8, i8* null, i64 1) to i64)
46   ; WASM32: icmp ult i64 {{.*}}, 2
47   %x = call i1 @llvm.type.test(i8* %p, metadata !"typeid1")
48   ret i1 %x
49 }
50
51 ; X86-LINUX:   define private void @[[JT]]() #[[ATTR:.*]] section ".text.cfi" align 8 {
52 ; X86-WIN32:   define private void @[[JT]]() section ".text.cfi" align 8 {
53 ; ARM:   define private void @[[JT]]() #[[ATTR:.*]] section ".text.cfi" align 4 {
54 ; THUMB: define private void @[[JT]]() #[[ATTR:.*]] section ".text.cfi" align 4 {
55
56 ; X86:      jmp ${0:c}@plt
57 ; X86-SAME: int3
58 ; X86-SAME: int3
59 ; X86-SAME: int3
60 ; X86-SAME: jmp ${1:c}@plt
61 ; X86-SAME: int3
62 ; X86-SAME: int3
63 ; X86-SAME: int3
64
65 ; ARM:      b $0
66 ; ARM-SAME: b $1
67
68 ; THUMB:      b.w $0
69 ; THUMB-SAME: b.w $1
70
71 ; NATIVE-SAME: "s,s"(void ()* @f.cfi, void ()* @g.cfi)
72
73 ; X86-LINUX: attributes #[[ATTR]] = { {{.*}}naked
74 ; ARM: attributes #[[ATTR]] = { {{.*}}naked
75 ; THUMB: attributes #[[ATTR]] = { {{.*}}naked{{.*}}"target-cpu"="cortex-a8"
76
77 ; WASM32: ![[I0]] = !{i64 1}
78 ; WASM32: ![[I1]] = !{i64 2}