[ARM] Adjust how NEON shifts are lowered
[llvm-core.git] / test / CodeGen / X86 / retpoline-external.ll
blob849660cdedbd4a8118a2e303d94f91931dce2204
1 ; RUN: llc -verify-machineinstrs -mtriple=x86_64-unknown < %s | FileCheck %s --implicit-check-not="jmp.*\*" --implicit-check-not="call.*\*" --check-prefix=X64
2 ; RUN: llc -verify-machineinstrs -mtriple=x86_64-unknown -O0 < %s | FileCheck %s --implicit-check-not="jmp.*\*" --implicit-check-not="call.*\*" --check-prefix=X64FAST
4 ; RUN: llc -verify-machineinstrs -mtriple=i686-unknown < %s | FileCheck %s --implicit-check-not="jmp.*\*" --implicit-check-not="call.*\*" --check-prefix=X86
5 ; RUN: llc -verify-machineinstrs -mtriple=i686-unknown -O0 < %s | FileCheck %s --implicit-check-not="jmp.*\*" --implicit-check-not="call.*\*" --check-prefix=X86FAST
7 declare void @bar(i32)
9 ; Test a simple indirect call and tail call.
10 define void @icall_reg(void (i32)* %fp, i32 %x) #0 {
11 entry:
12   tail call void @bar(i32 %x)
13   tail call void %fp(i32 %x)
14   tail call void @bar(i32 %x)
15   tail call void %fp(i32 %x)
16   ret void
19 ; X64-LABEL: icall_reg:
20 ; X64-DAG:   movq %rdi, %[[fp:[^ ]*]]
21 ; X64-DAG:   movl %esi, %[[x:[^ ]*]]
22 ; X64:       movl %esi, %edi
23 ; X64:       callq bar
24 ; X64-DAG:   movl %[[x]], %edi
25 ; X64-DAG:   movq %[[fp]], %r11
26 ; X64:       callq __x86_indirect_thunk_r11
27 ; X64:       movl %[[x]], %edi
28 ; X64:       callq bar
29 ; X64-DAG:   movl %[[x]], %edi
30 ; X64-DAG:   movq %[[fp]], %r11
31 ; X64:       jmp __x86_indirect_thunk_r11 # TAILCALL
33 ; X64FAST-LABEL: icall_reg:
34 ; X64FAST:       callq bar
35 ; X64FAST:       callq __x86_indirect_thunk_r11
36 ; X64FAST:       callq bar
37 ; X64FAST:       jmp __x86_indirect_thunk_r11 # TAILCALL
39 ; X86-LABEL: icall_reg:
40 ; X86-DAG:   movl 12(%esp), %[[fp:[^ ]*]]
41 ; X86-DAG:   movl 16(%esp), %[[x:[^ ]*]]
42 ; X86:       pushl %[[x]]
43 ; X86:       calll bar
44 ; X86:       movl %[[fp]], %eax
45 ; X86:       pushl %[[x]]
46 ; X86:       calll __x86_indirect_thunk_eax
47 ; X86:       pushl %[[x]]
48 ; X86:       calll bar
49 ; X86:       movl %[[fp]], %eax
50 ; X86:       pushl %[[x]]
51 ; X86:       calll __x86_indirect_thunk_eax
52 ; X86-NOT:   # TAILCALL
54 ; X86FAST-LABEL: icall_reg:
55 ; X86FAST:       calll bar
56 ; X86FAST:       calll __x86_indirect_thunk_eax
57 ; X86FAST:       calll bar
58 ; X86FAST:       calll __x86_indirect_thunk_eax
61 @global_fp = external global void (i32)*
63 ; Test an indirect call through a global variable.
64 define void @icall_global_fp(i32 %x, void (i32)** %fpp) #0 {
65   %fp1 = load void (i32)*, void (i32)** @global_fp
66   call void %fp1(i32 %x)
67   %fp2 = load void (i32)*, void (i32)** @global_fp
68   tail call void %fp2(i32 %x)
69   ret void
72 ; X64-LABEL: icall_global_fp:
73 ; X64-DAG:   movl %edi, %[[x:[^ ]*]]
74 ; X64-DAG:   movq global_fp(%rip), %r11
75 ; X64:       callq __x86_indirect_thunk_r11
76 ; X64-DAG:   movl %[[x]], %edi
77 ; X64-DAG:   movq global_fp(%rip), %r11
78 ; X64:       jmp __x86_indirect_thunk_r11 # TAILCALL
80 ; X64FAST-LABEL: icall_global_fp:
81 ; X64FAST:       movq global_fp(%rip), %r11
82 ; X64FAST:       callq __x86_indirect_thunk_r11
83 ; X64FAST:       movq global_fp(%rip), %r11
84 ; X64FAST:       jmp __x86_indirect_thunk_r11 # TAILCALL
86 ; X86-LABEL: icall_global_fp:
87 ; X86:       movl global_fp, %eax
88 ; X86:       pushl 4(%esp)
89 ; X86:       calll __x86_indirect_thunk_eax
90 ; X86:       addl $4, %esp
91 ; X86:       movl global_fp, %eax
92 ; X86:       jmp __x86_indirect_thunk_eax # TAILCALL
94 ; X86FAST-LABEL: icall_global_fp:
95 ; X86FAST:       calll __x86_indirect_thunk_eax
96 ; X86FAST:       jmp __x86_indirect_thunk_eax # TAILCALL
99 %struct.Foo = type { void (%struct.Foo*)** }
101 ; Test an indirect call through a vtable.
102 define void @vcall(%struct.Foo* %obj) #0 {
103   %vptr_field = getelementptr %struct.Foo, %struct.Foo* %obj, i32 0, i32 0
104   %vptr = load void (%struct.Foo*)**, void (%struct.Foo*)*** %vptr_field
105   %vslot = getelementptr void(%struct.Foo*)*, void(%struct.Foo*)** %vptr, i32 1
106   %fp = load void(%struct.Foo*)*, void(%struct.Foo*)** %vslot
107   tail call void %fp(%struct.Foo* %obj)
108   tail call void %fp(%struct.Foo* %obj)
109   ret void
112 ; X64-LABEL: vcall:
113 ; X64:       movq %rdi, %[[obj:[^ ]*]]
114 ; X64:       movq (%rdi), %[[vptr:[^ ]*]]
115 ; X64:       movq 8(%[[vptr]]), %[[fp:[^ ]*]]
116 ; X64:       movq %[[fp]], %r11
117 ; X64:       callq __x86_indirect_thunk_r11
118 ; X64-DAG:   movq %[[obj]], %rdi
119 ; X64-DAG:   movq %[[fp]], %r11
120 ; X64:       jmp __x86_indirect_thunk_r11 # TAILCALL
122 ; X64FAST-LABEL: vcall:
123 ; X64FAST:       callq __x86_indirect_thunk_r11
124 ; X64FAST:       jmp __x86_indirect_thunk_r11 # TAILCALL
126 ; X86-LABEL: vcall:
127 ; X86:       movl 8(%esp), %[[obj:[^ ]*]]
128 ; X86:       movl (%[[obj]]), %[[vptr:[^ ]*]]
129 ; X86:       movl 4(%[[vptr]]), %[[fp:[^ ]*]]
130 ; X86:       movl %[[fp]], %eax
131 ; X86:       pushl %[[obj]]
132 ; X86:       calll __x86_indirect_thunk_eax
133 ; X86:       addl $4, %esp
134 ; X86:       movl %[[fp]], %eax
135 ; X86:       jmp __x86_indirect_thunk_eax # TAILCALL
137 ; X86FAST-LABEL: vcall:
138 ; X86FAST:       calll __x86_indirect_thunk_eax
139 ; X86FAST:       jmp __x86_indirect_thunk_eax # TAILCALL
142 declare void @direct_callee()
144 define void @direct_tail() #0 {
145   tail call void @direct_callee()
146   ret void
149 ; X64-LABEL: direct_tail:
150 ; X64:       jmp direct_callee # TAILCALL
151 ; X64FAST-LABEL: direct_tail:
152 ; X64FAST:   jmp direct_callee # TAILCALL
153 ; X86-LABEL: direct_tail:
154 ; X86:       jmp direct_callee # TAILCALL
155 ; X86FAST-LABEL: direct_tail:
156 ; X86FAST:   jmp direct_callee # TAILCALL
159 ; Lastly check that no thunks were emitted.
160 ; X64-NOT: __{{.*}}_retpoline_{{.*}}:
161 ; X64FAST-NOT: __{{.*}}_retpoline_{{.*}}:
162 ; X86-NOT: __{{.*}}_retpoline_{{.*}}:
163 ; X86FAST-NOT: __{{.*}}_retpoline_{{.*}}:
166 attributes #0 = { "target-features"="+retpoline-indirect-calls,+retpoline-external-thunk" }