1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -verify-machineinstrs < %s 2>&1 | FileCheck %s
4 target triple = "x86_64-pc-linux-gnu"
6 declare void @"some_call"(ptr addrspace(1))
7 declare ptr addrspace(1) @"some_other_call"(ptr addrspace(1))
9 declare i32 @"personality_function"()
11 define ptr addrspace(1) @test_basic(ptr addrspace(1) %obj,
12 ; CHECK-LABEL: test_basic:
13 ; CHECK: # %bb.0: # %entry
14 ; CHECK-NEXT: subq $24, %rsp
15 ; CHECK-NEXT: .cfi_def_cfa_offset 32
16 ; CHECK-NEXT: movq %rdi, {{[0-9]+}}(%rsp)
17 ; CHECK-NEXT: movq %rsi, {{[0-9]+}}(%rsp)
19 ; CHECK-NEXT: callq some_call@PLT
22 ; CHECK-NEXT: # %bb.1: # %invoke_safepoint_normal_dest
23 ; CHECK-NEXT: movq {{[0-9]+}}(%rsp), %rax
24 ; CHECK-NEXT: addq $24, %rsp
25 ; CHECK-NEXT: .cfi_def_cfa_offset 8
27 ; CHECK-NEXT: .LBB0_2: # %exceptional_return
28 ; CHECK-NEXT: .cfi_def_cfa_offset 32
30 ; CHECK-NEXT: movq {{[0-9]+}}(%rsp), %rax
31 ; CHECK-NEXT: addq $24, %rsp
32 ; CHECK-NEXT: .cfi_def_cfa_offset 8
34 ptr addrspace(1) %obj1)
35 gc "statepoint-example" personality ptr @"personality_function" {
37 %0 = invoke token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 0, i32 0, ptr elementtype(void (ptr addrspace(1))) @some_call, i32 1, i32 0, ptr addrspace(1) %obj, i32 0, i32 0) ["gc-live" (ptr addrspace(1) %obj, ptr addrspace(1) %obj1), "deopt" (i32 0, i32 -1, i32 0, i32 0, i32 0)]
38 to label %invoke_safepoint_normal_dest unwind label %exceptional_return
40 invoke_safepoint_normal_dest:
41 %obj.relocated = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %0, i32 0, i32 0)
42 %obj1.relocated = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %0, i32 1, i32 1)
43 br label %normal_return
46 ret ptr addrspace(1) %obj.relocated
49 %landing_pad = landingpad token
51 %obj.relocated1 = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %landing_pad, i32 0, i32 0)
52 %obj1.relocated1 = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %landing_pad, i32 1, i32 1)
53 ret ptr addrspace(1) %obj1.relocated1
55 ; CHECK-LABEL: GCC_except_table{{[0-9]+}}:
56 ; CHECK: .uleb128 .Ltmp{{[0-9]+}}-.Ltmp{{[0-9]+}}
57 ; CHECK: .uleb128 .Ltmp{{[0-9]+}}-.Lfunc_begin{{[0-9]+}}
61 define ptr addrspace(1) @test_result(ptr addrspace(1) %obj,
62 ; CHECK-LABEL: test_result:
63 ; CHECK: # %bb.0: # %entry
64 ; CHECK-NEXT: pushq %rax
65 ; CHECK-NEXT: .cfi_def_cfa_offset 16
66 ; CHECK-NEXT: movq %rdi, (%rsp)
68 ; CHECK-NEXT: callq some_other_call@PLT
71 ; CHECK-NEXT: # %bb.1: # %normal_return
72 ; CHECK-NEXT: popq %rcx
73 ; CHECK-NEXT: .cfi_def_cfa_offset 8
75 ; CHECK-NEXT: .LBB1_2: # %exceptional_return
76 ; CHECK-NEXT: .cfi_def_cfa_offset 16
78 ; CHECK-NEXT: movq (%rsp), %rax
79 ; CHECK-NEXT: popq %rcx
80 ; CHECK-NEXT: .cfi_def_cfa_offset 8
82 ptr addrspace(1) %obj1)
83 gc "statepoint-example" personality ptr @personality_function {
85 %0 = invoke token (i64, i32, ptr addrspace(1) (ptr addrspace(1))*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 0, i32 0, ptr addrspace(1) (ptr addrspace(1))* elementtype(ptr addrspace(1) (ptr addrspace(1))) @some_other_call, i32 1, i32 0, ptr addrspace(1) %obj, i32 0, i32 0) ["gc-live"(ptr addrspace(1) %obj, ptr addrspace(1) %obj1)]
86 to label %normal_return unwind label %exceptional_return
89 %ret_val = call ptr addrspace(1) @llvm.experimental.gc.result.p1(token %0)
90 ret ptr addrspace(1) %ret_val
93 %landing_pad = landingpad token
95 %obj.relocated = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %landing_pad, i32 0, i32 0)
96 ret ptr addrspace(1) %obj.relocated
98 ; CHECK-LABEL: GCC_except_table{{[0-9]+}}:
99 ; CHECK: .uleb128 .Ltmp{{[0-9]+}}-.Ltmp{{[0-9]+}}
100 ; CHECK: .uleb128 .Ltmp{{[0-9]+}}-.Lfunc_begin{{[0-9]+}}
104 define ptr addrspace(1) @test_same_val(i1 %cond, ptr addrspace(1) %val1, ptr addrspace(1) %val2, ptr addrspace(1) %val3)
105 ; CHECK-LABEL: test_same_val:
106 ; CHECK: # %bb.0: # %entry
107 ; CHECK-NEXT: pushq %rbx
108 ; CHECK-NEXT: .cfi_def_cfa_offset 16
109 ; CHECK-NEXT: subq $16, %rsp
110 ; CHECK-NEXT: .cfi_def_cfa_offset 32
111 ; CHECK-NEXT: .cfi_offset %rbx, -16
112 ; CHECK-NEXT: movl %edi, %ebx
113 ; CHECK-NEXT: testb $1, %bl
114 ; CHECK-NEXT: je .LBB2_3
115 ; CHECK-NEXT: # %bb.1: # %left
116 ; CHECK-NEXT: movq %rsi, (%rsp)
117 ; CHECK-NEXT: movq %rdx, {{[0-9]+}}(%rsp)
118 ; CHECK-NEXT: .Ltmp11:
119 ; CHECK-NEXT: movq %rsi, %rdi
120 ; CHECK-NEXT: callq some_call@PLT
121 ; CHECK-NEXT: .Ltmp14:
122 ; CHECK-NEXT: .Ltmp12:
123 ; CHECK-NEXT: # %bb.2: # %left.relocs
124 ; CHECK-NEXT: movq (%rsp), %rax
125 ; CHECK-NEXT: movq {{[0-9]+}}(%rsp), %rcx
126 ; CHECK-NEXT: jmp .LBB2_5
127 ; CHECK-NEXT: .LBB2_3: # %right
128 ; CHECK-NEXT: movq %rdx, (%rsp)
129 ; CHECK-NEXT: movq %rcx, {{[0-9]+}}(%rsp)
130 ; CHECK-NEXT: .Ltmp8:
131 ; CHECK-NEXT: movq %rsi, %rdi
132 ; CHECK-NEXT: callq some_call@PLT
133 ; CHECK-NEXT: .Ltmp15:
134 ; CHECK-NEXT: .Ltmp9:
135 ; CHECK-NEXT: # %bb.4: # %right.relocs
136 ; CHECK-NEXT: movq (%rsp), %rcx
137 ; CHECK-NEXT: movq {{[0-9]+}}(%rsp), %rax
138 ; CHECK-NEXT: .LBB2_5: # %normal_return
139 ; CHECK-NEXT: testb $1, %bl
140 ; CHECK-NEXT: cmoveq %rcx, %rax
141 ; CHECK-NEXT: .LBB2_6: # %normal_return
142 ; CHECK-NEXT: addq $16, %rsp
143 ; CHECK-NEXT: .cfi_def_cfa_offset 16
144 ; CHECK-NEXT: popq %rbx
145 ; CHECK-NEXT: .cfi_def_cfa_offset 8
147 ; CHECK-NEXT: .LBB2_9: # %exceptional_return.right
148 ; CHECK-NEXT: .cfi_def_cfa_offset 32
149 ; CHECK-NEXT: .Ltmp10:
150 ; CHECK-NEXT: movq (%rsp), %rax
151 ; CHECK-NEXT: jmp .LBB2_6
152 ; CHECK-NEXT: .LBB2_7: # %exceptional_return.left
153 ; CHECK-NEXT: .Ltmp13:
154 ; CHECK-NEXT: movq (%rsp), %rax
155 ; CHECK-NEXT: jmp .LBB2_6
156 gc "statepoint-example" personality ptr @"personality_function" {
158 br i1 %cond, label %left, label %right
161 %sp1 = invoke token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 0, i32 0, ptr elementtype(void (ptr addrspace(1))) @some_call, i32 1, i32 0, ptr addrspace(1) %val1, i32 0, i32 0) ["gc-live"(ptr addrspace(1) %val1, ptr addrspace(1) %val2)]
162 to label %left.relocs unwind label %exceptional_return.left
165 %val1.relocated = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %sp1, i32 0, i32 0)
166 %val2.relocated_left = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %sp1, i32 1, i32 1)
167 br label %normal_return
170 %sp2 = invoke token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 0, i32 0, ptr elementtype(void (ptr addrspace(1))) @some_call, i32 1, i32 0, ptr addrspace(1) %val1, i32 0, i32 0) ["gc-live"(ptr addrspace(1) %val2, ptr addrspace(1) %val3)]
171 to label %right.relocs unwind label %exceptional_return.right
174 %val2.relocated_right = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %sp2, i32 0, i32 0)
175 %val3.relocated = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %sp2, i32 1, i32 1)
176 br label %normal_return
179 %a1 = phi ptr addrspace(1) [%val1.relocated, %left.relocs], [%val3.relocated, %right.relocs]
180 %a2 = phi ptr addrspace(1) [%val2.relocated_left, %left.relocs], [%val2.relocated_right, %right.relocs]
181 %ret = select i1 %cond, ptr addrspace(1) %a1, ptr addrspace(1) %a2
182 ret ptr addrspace(1) %ret
184 exceptional_return.left:
185 %landing_pad = landingpad token
187 %val.relocated2 = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %landing_pad, i32 0, i32 0)
188 ret ptr addrspace(1) %val.relocated2
190 exceptional_return.right:
191 %landing_pad1 = landingpad token
193 %val.relocated3 = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %landing_pad1, i32 0, i32 0)
194 ret ptr addrspace(1) %val.relocated3
197 define ptr addrspace(1) @test_null_undef(ptr addrspace(1) %val1)
198 ; CHECK-LABEL: test_null_undef:
199 ; CHECK: # %bb.0: # %entry
200 ; CHECK-NEXT: pushq %rax
201 ; CHECK-NEXT: .cfi_def_cfa_offset 16
202 ; CHECK-NEXT: .Ltmp16:
203 ; CHECK-NEXT: callq some_call@PLT
204 ; CHECK-NEXT: .Ltmp19:
205 ; CHECK-NEXT: .Ltmp17:
206 ; CHECK-NEXT: .LBB3_1: # %normal_return
207 ; CHECK-NEXT: xorl %eax, %eax
208 ; CHECK-NEXT: popq %rcx
209 ; CHECK-NEXT: .cfi_def_cfa_offset 8
211 ; CHECK-NEXT: .LBB3_2: # %exceptional_return
212 ; CHECK-NEXT: .cfi_def_cfa_offset 16
213 ; CHECK-NEXT: .Ltmp18:
214 ; CHECK-NEXT: jmp .LBB3_1
215 gc "statepoint-example" personality ptr @"personality_function" {
217 %sp1 = invoke token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 0, i32 0, ptr elementtype(void (ptr addrspace(1))) @some_call, i32 1, i32 0, ptr addrspace(1) %val1, i32 0, i32 0) ["gc-live"(ptr addrspace(1) null, ptr addrspace(1) undef)]
218 to label %normal_return unwind label %exceptional_return
221 %null.relocated = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %sp1, i32 0, i32 0)
222 %undef.relocated = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %sp1, i32 1, i32 1)
223 ret ptr addrspace(1) %null.relocated
226 %landing_pad = landingpad token
228 %null.relocated2 = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %landing_pad, i32 0, i32 0)
229 %undef.relocated2 = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %landing_pad, i32 1, i32 1)
230 ret ptr addrspace(1) %null.relocated2
233 define ptr addrspace(1) @test_alloca_and_const(ptr addrspace(1) %val1)
234 ; CHECK-LABEL: test_alloca_and_const:
235 ; CHECK: # %bb.0: # %entry
236 ; CHECK-NEXT: pushq %rax
237 ; CHECK-NEXT: .cfi_def_cfa_offset 16
238 ; CHECK-NEXT: .Ltmp20:
239 ; CHECK-NEXT: callq some_call@PLT
240 ; CHECK-NEXT: .Ltmp23:
241 ; CHECK-NEXT: .Ltmp21:
242 ; CHECK-NEXT: # %bb.1: # %normal_return
243 ; CHECK-NEXT: leaq {{[0-9]+}}(%rsp), %rax
244 ; CHECK-NEXT: popq %rcx
245 ; CHECK-NEXT: .cfi_def_cfa_offset 8
247 ; CHECK-NEXT: .LBB4_2: # %exceptional_return
248 ; CHECK-NEXT: .cfi_def_cfa_offset 16
249 ; CHECK-NEXT: .Ltmp22:
250 ; CHECK-NEXT: movl $15, %eax
251 ; CHECK-NEXT: popq %rcx
252 ; CHECK-NEXT: .cfi_def_cfa_offset 8
254 gc "statepoint-example" personality ptr @"personality_function" {
257 %aa = addrspacecast ptr %a to ptr addrspace(1)
258 %c = inttoptr i64 15 to ptr addrspace(1)
259 %sp = invoke token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 0, i32 0, ptr elementtype(void (ptr addrspace(1))) @some_call, i32 1, i32 0, ptr addrspace(1) %val1, i32 0, i32 0) ["gc-live"(ptr addrspace(1) %aa, ptr addrspace(1) %c)]
260 to label %normal_return unwind label %exceptional_return
263 %aa.rel = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %sp, i32 0, i32 0)
264 ret ptr addrspace(1) %aa.rel
267 %landing_pad = landingpad token
269 %aa.rel2 = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %landing_pad, i32 1, i32 1)
270 ret ptr addrspace(1) %aa.rel2
273 declare token @llvm.experimental.gc.statepoint.p0(i64, i32, ptr, i32, i32, ...)
275 declare ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token, i32, i32)
276 declare ptr addrspace(1) @llvm.experimental.gc.result.p1(token)