llvm.org GIT mirror llvm / 407aa26
Merging r294551: ------------------------------------------------------------------------ r294551 | arnolds | 2017-02-08 17:52:17 -0800 (Wed, 08 Feb 2017) | 10 lines SwiftCC: swifterror register cannot be as the base register Functions that have a dynamic alloca require a base register which is defined to be X19 on AArch64 and r6 on ARM. We have defined the swifterror register to be the same register. Use a different callee save register for swifterror instead: X21 on AArch64 R8 on ARM rdar://30433803 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_40@295079 91177308-0d34-0410-b5e6-96231b3b80d8 Hans Wennborg 2 years ago
4 changed file(s) with 179 addition(s) and 179 deletion(s). Raw diff Collapse all Expand all
9090 CCIfType<[v2f32], CCBitConvertToType>,
9191 CCIfType<[v2f64, v4f32], CCBitConvertToType>,
9292
93 CCIfSwiftError19], [W19]>>>,
93 CCIfSwiftError21], [W21]>>>,
9494
9595 // Big endian vectors must be passed as if they were 1-element vectors so that
9696 // their lanes are in a consistent order.
137137 // Pass SwiftSelf in a callee saved register.
138138 CCIfSwiftSelf>>,
139139
140 // A SwiftError is passed in X19.
141 CCIfSwiftError>>,
140 // A SwiftError is passed in X21.
141 CCIfSwiftError>>,
142142
143143 CCIfConsecutiveRegs>,
144144
288288 def CSR_AArch64_AAPCS_ThisReturn : CalleeSavedRegs<(add CSR_AArch64_AAPCS, X0)>;
289289
290290 def CSR_AArch64_AAPCS_SwiftError
291 : CalleeSavedRegs<(sub CSR_AArch64_AAPCS, X19)>;
291 : CalleeSavedRegs<(sub CSR_AArch64_AAPCS, X21)>;
292292
293293 // The function used by Darwin to obtain the address of a thread-local variable
294294 // guarantees more than a normal AAPCS function. x16 and x17 are used on the
2525 // Pass SwiftSelf in a callee saved register.
2626 CCIfSwiftSelf>>,
2727
28 // A SwiftError is passed in R6.
29 CCIfSwiftError>>,
28 // A SwiftError is passed in R8.
29 CCIfSwiftError>>,
3030
3131 // Handle all vector types as either f64 or v2f64.
3232 CCIfType<[v1i64, v2i32, v4i16, v8i8, v2f32], CCBitConvertToType>,
5050 // Pass SwiftSelf in a callee saved register.
5151 CCIfSwiftSelf>>,
5252
53 // A SwiftError is returned in R6.
54 CCIfSwiftError>>,
53 // A SwiftError is returned in R8.
54 CCIfSwiftError>>,
5555
5656 // Handle all vector types as either f64 or v2f64.
5757 CCIfType<[v1i64, v2i32, v4i16, v8i8, v2f32], CCBitConvertToType>,
165165 // Pass SwiftSelf in a callee saved register.
166166 CCIfSwiftSelf>>,
167167
168 // A SwiftError is passed in R6.
169 CCIfSwiftError>>,
168 // A SwiftError is passed in R8.
169 CCIfSwiftError>>,
170170
171171 CCIfType<[f64, v2f64], CCCustom<"CC_ARM_AAPCS_Custom_f64">>,
172172 CCIfType<[f32], CCBitConvertToType>,
181181 // Pass SwiftSelf in a callee saved register.
182182 CCIfSwiftSelf>>,
183183
184 // A SwiftError is returned in R6.
185 CCIfSwiftError>>,
184 // A SwiftError is returned in R8.
185 CCIfSwiftError>>,
186186
187187 CCIfType<[f64, v2f64], CCCustom<"RetCC_ARM_AAPCS_Custom_f64">>,
188188 CCIfType<[f32], CCBitConvertToType>,
205205 // Pass SwiftSelf in a callee saved register.
206206 CCIfSwiftSelf>>,
207207
208 // A SwiftError is passed in R6.
209 CCIfSwiftError>>,
208 // A SwiftError is passed in R8.
209 CCIfSwiftError>>,
210210
211211 // HFAs are passed in a contiguous block of registers, or on the stack
212212 CCIfConsecutiveRegs>,
226226 // Pass SwiftSelf in a callee saved register.
227227 CCIfSwiftSelf>>,
228228
229 // A SwiftError is returned in R6.
230 CCIfSwiftError>>,
229 // A SwiftError is returned in R8.
230 CCIfSwiftError>>,
231231
232232 CCIfType<[v2f64], CCAssignToReg<[Q0, Q1, Q2, Q3]>>,
233233 CCIfType<[f64], CCAssignToReg<[D0, D1, D2, D3, D4, D5, D6, D7]>>,
266266 // Also save R7-R4 first to match the stack frame fixed spill areas.
267267 def CSR_iOS : CalleeSavedRegs<(add LR, R7, R6, R5, R4, (sub CSR_AAPCS, R9))>;
268268
269 // R6 is used to pass swifterror, remove it from CSR.
270 def CSR_iOS_SwiftError : CalleeSavedRegs<(sub CSR_iOS, R6)>;
269 // R8 is used to pass swifterror, remove it from CSR.
270 def CSR_iOS_SwiftError : CalleeSavedRegs<(sub CSR_iOS, R8)>;
271271
272272 def CSR_iOS_ThisReturn : CalleeSavedRegs<(add LR, R7, R6, R5, R4,
273273 (sub CSR_AAPCS_ThisReturn, R9))>;
1212 ; CHECK-APPLE: malloc
1313 ; CHECK-APPLE: orr [[ID:w[0-9]+]], wzr, #0x1
1414 ; CHECK-APPLE: strb [[ID]], [x0, #8]
15 ; CHECK-APPLE: mov x19, x0
16 ; CHECK-APPLE-NOT: x19
15 ; CHECK-APPLE: mov x21, x0
16 ; CHECK-APPLE-NOT: x21
1717
1818 ; CHECK-O0-LABEL: foo:
1919 ; CHECK-O0: orr w{{.*}}, wzr, #0x10
2020 ; CHECK-O0: malloc
21 ; CHECK-O0: mov x19, x0
22 ; CHECK-O0-NOT: x19
21 ; CHECK-O0: mov x21, x0
22 ; CHECK-O0-NOT: x21
2323 ; CHECK-O0: orr [[ID:w[0-9]+]], wzr, #0x1
24 ; CHECK-O0-NOT: x19
24 ; CHECK-O0-NOT: x21
2525 ; CHECK-O0: strb [[ID]], [x0, #8]
26 ; CHECK-O0-NOT: x19
26 ; CHECK-O0-NOT: x21
2727 entry:
2828 %call = call i8* @malloc(i64 16)
2929 %call.0 = bitcast i8* %call to %swift_error*
3737 define float @caller(i8* %error_ref) {
3838 ; CHECK-APPLE-LABEL: caller:
3939 ; CHECK-APPLE: mov [[ID:x[0-9]+]], x0
40 ; CHECK-APPLE: mov x19, xzr
40 ; CHECK-APPLE: mov x21, xzr
4141 ; CHECK-APPLE: bl {{.*}}foo
42 ; CHECK-APPLE: cbnz x19
42 ; CHECK-APPLE: cbnz x21
4343 ; Access part of the error object and save it to error_ref
44 ; CHECK-APPLE: ldrb [[CODE:w[0-9]+]], [x19, #8]
44 ; CHECK-APPLE: ldrb [[CODE:w[0-9]+]], [x21, #8]
4545 ; CHECK-APPLE: strb [[CODE]], [{{.*}}[[ID]]]
46 ; CHECK-APPLE: mov x0, x19
46 ; CHECK-APPLE: mov x0, x21
4747 ; CHECK-APPLE: bl {{.*}}free
4848
4949 ; CHECK-O0-LABEL: caller:
50 ; CHECK-O0: mov x19
50 ; CHECK-O0: mov x21
5151 ; CHECK-O0: bl {{.*}}foo
52 ; CHECK-O0: mov [[ID:x[0-9]+]], x19
53 ; CHECK-O0: cbnz x19
52 ; CHECK-O0: mov [[ID:x[0-9]+]], x21
53 ; CHECK-O0: cbnz x21
5454 entry:
5555 %error_ptr_ref = alloca swifterror %swift_error*
5656 store %swift_error* null, %swift_error** %error_ptr_ref
7474 ; CHECK-APPLE-LABEL: caller2:
7575 ; CHECK-APPLE: mov [[ID:x[0-9]+]], x0
7676 ; CHECK-APPLE: fmov [[CMP:s[0-9]+]], #1.0
77 ; CHECK-APPLE: mov x19, xzr
77 ; CHECK-APPLE: mov x21, xzr
7878 ; CHECK-APPLE: bl {{.*}}foo
79 ; CHECK-APPLE: cbnz x19
79 ; CHECK-APPLE: cbnz x21
8080 ; CHECK-APPLE: fcmp s0, [[CMP]]
8181 ; CHECK-APPLE: b.le
8282 ; Access part of the error object and save it to error_ref
83 ; CHECK-APPLE: ldrb [[CODE:w[0-9]+]], [x19, #8]
83 ; CHECK-APPLE: ldrb [[CODE:w[0-9]+]], [x21, #8]
8484 ; CHECK-APPLE: strb [[CODE]], [{{.*}}[[ID]]]
85 ; CHECK-APPLE: mov x0, x19
85 ; CHECK-APPLE: mov x0, x21
8686 ; CHECK-APPLE: bl {{.*}}free
8787
8888 ; CHECK-O0-LABEL: caller2:
89 ; CHECK-O0: mov x19
89 ; CHECK-O0: mov x21
9090 ; CHECK-O0: bl {{.*}}foo
91 ; CHECK-O0: mov [[ID:x[0-9]+]], x19
92 ; CHECK-O0: cbnz x19
91 ; CHECK-O0: mov [[ID:x[0-9]+]], x21
92 ; CHECK-O0: cbnz x21
9393 entry:
9494 %error_ptr_ref = alloca swifterror %swift_error*
9595 br label %bb_loop
122122 ; CHECK-APPLE: malloc
123123 ; CHECK-APPLE: orr [[ID:w[0-9]+]], wzr, #0x1
124124 ; CHECK-APPLE: strb [[ID]], [x0, #8]
125 ; CHECK-APPLE: mov x19, x0
126 ; CHECK-APPLE-NOT: x19
125 ; CHECK-APPLE: mov x21, x0
126 ; CHECK-APPLE-NOT: x21
127127 ; CHECK-APPLE: ret
128128
129129 ; CHECK-O0-LABEL: foo_if:
130 ; spill x19
131 ; CHECK-O0: str x19, [sp, [[SLOT:#[0-9]+]]]
130 ; spill x21
131 ; CHECK-O0: str x21, [sp, [[SLOT:#[0-9]+]]]
132132 ; CHECK-O0: cbz w0
133133 ; CHECK-O0: orr w{{.*}}, wzr, #0x10
134134 ; CHECK-O0: malloc
135135 ; CHECK-O0: mov [[ID:x[0-9]+]], x0
136136 ; CHECK-O0: orr [[ID2:w[0-9]+]], wzr, #0x1
137137 ; CHECK-O0: strb [[ID2]], [x0, #8]
138 ; CHECK-O0: mov x19, [[ID]]
138 ; CHECK-O0: mov x21, [[ID]]
139139 ; CHECK-O0: ret
140140 ; reload from stack
141141 ; CHECK-O0: ldr [[ID3:x[0-9]+]], [sp, [[SLOT]]]
142 ; CHECK-O0: mov x19, [[ID3]]
142 ; CHECK-O0: mov x21, [[ID3]]
143143 ; CHECK-O0: ret
144144 entry:
145145 %cond = icmp ne i32 %cc, 0
161161 ; under a certain condition inside a loop.
162162 define float @foo_loop(%swift_error** swifterror %error_ptr_ref, i32 %cc, float %cc2) {
163163 ; CHECK-APPLE-LABEL: foo_loop:
164 ; CHECK-APPLE: mov x0, x19
164 ; CHECK-APPLE: mov x0, x21
165165 ; CHECK-APPLE: cbz
166166 ; CHECK-APPLE: orr w0, wzr, #0x10
167167 ; CHECK-APPLE: malloc
168168 ; CHECK-APPLE: strb w{{.*}}, [x0, #8]
169169 ; CHECK-APPLE: fcmp
170170 ; CHECK-APPLE: b.le
171 ; CHECK-APPLE: mov x19, x0
171 ; CHECK-APPLE: mov x21, x0
172172 ; CHECK-APPLE: ret
173173
174174 ; CHECK-O0-LABEL: foo_loop:
175 ; spill x19
176 ; CHECK-O0: str x19, [sp, [[SLOT:#[0-9]+]]]
175 ; spill x21
176 ; CHECK-O0: str x21, [sp, [[SLOT:#[0-9]+]]]
177177 ; CHECK-O0: b [[BB1:[A-Za-z0-9_]*]]
178178 ; CHECK-O0: [[BB1]]:
179179 ; CHECK-O0: ldr x0, [sp, [[SLOT]]]
192192 ; CHECK-O0: b.le [[BB1]]
193193 ; reload from stack
194194 ; CHECK-O0: ldr [[ID3:x[0-9]+]], [sp]
195 ; CHECK-O0: mov x19, [[ID3]]
195 ; CHECK-O0: mov x21, [[ID3]]
196196 ; CHECK-O0: ret
197197 entry:
198198 br label %bb_loop
228228 ; CHECK-APPLE: orr [[ID:w[0-9]+]], wzr, #0x1
229229 ; CHECK-APPLE: strb [[ID]], [x0, #8]
230230 ; CHECK-APPLE: str w{{.*}}, [{{.*}}[[SRET]], #4]
231 ; CHECK-APPLE: mov x19, x0
232 ; CHECK-APPLE-NOT: x19
231 ; CHECK-APPLE: mov x21, x0
232 ; CHECK-APPLE-NOT: x21
233233
234234 ; CHECK-O0-LABEL: foo_sret:
235235 ; CHECK-O0: orr w{{.*}}, wzr, #0x10
236236 ; spill x8
237237 ; CHECK-O0-DAG: str x8
238 ; spill x19
239 ; CHECK-O0-DAG: str x19
238 ; spill x21
239 ; CHECK-O0-DAG: str x21
240240 ; CHECK-O0: malloc
241241 ; CHECK-O0: orr [[ID:w[0-9]+]], wzr, #0x1
242242 ; CHECK-O0: strb [[ID]], [x0, #8]
243243 ; reload from stack
244244 ; CHECK-O0: ldr [[SRET:x[0-9]+]]
245245 ; CHECK-O0: str w{{.*}}, [{{.*}}[[SRET]], #4]
246 ; CHECK-O0: mov x19
247 ; CHECK-O0-NOT: x19
246 ; CHECK-O0: mov x21
247 ; CHECK-O0-NOT: x21
248248 entry:
249249 %call = call i8* @malloc(i64 16)
250250 %call.0 = bitcast i8* %call to %swift_error*
260260 define float @caller3(i8* %error_ref) {
261261 ; CHECK-APPLE-LABEL: caller3:
262262 ; CHECK-APPLE: mov [[ID:x[0-9]+]], x0
263 ; CHECK-APPLE: mov x19, xzr
263 ; CHECK-APPLE: mov x21, xzr
264264 ; CHECK-APPLE: bl {{.*}}foo_sret
265 ; CHECK-APPLE: cbnz x19
265 ; CHECK-APPLE: cbnz x21
266266 ; Access part of the error object and save it to error_ref
267 ; CHECK-APPLE: ldrb [[CODE:w[0-9]+]], [x19, #8]
267 ; CHECK-APPLE: ldrb [[CODE:w[0-9]+]], [x21, #8]
268268 ; CHECK-APPLE: strb [[CODE]], [{{.*}}[[ID]]]
269 ; CHECK-APPLE: mov x0, x19
269 ; CHECK-APPLE: mov x0, x21
270270 ; CHECK-APPLE: bl {{.*}}free
271271
272272 ; CHECK-O0-LABEL: caller3:
273273 ; spill x0
274274 ; CHECK-O0: str x0
275 ; CHECK-O0: mov x19
275 ; CHECK-O0: mov x21
276276 ; CHECK-O0: bl {{.*}}foo_sret
277 ; CHECK-O0: mov [[ID2:x[0-9]+]], x19
278 ; CHECK-O0: cbnz [[ID2]]
277 ; CHECK-O0: mov [[ID2:x[0-9]+]], x21
278 ; CHECK-O0: cbnz x21
279279 ; Access part of the error object and save it to error_ref
280280 ; reload from stack
281281 ; CHECK-O0: ldrb [[CODE:w[0-9]+]]
322322 ; Third vararg
323323 ; CHECK-APPLE: ldr {{w[0-9]+}}, [{{x[0-9]+}}]
324324
325 ; CHECK-APPLE: mov x19, x0
326 ; CHECK-APPLE-NOT: x19
325 ; CHECK-APPLE: mov x21, x0
326 ; CHECK-APPLE-NOT: x21
327327 entry:
328328 %call = call i8* @malloc(i64 16)
329329 %call.0 = bitcast i8* %call to %swift_error*
355355 ; CHECK-APPLE: stp {{x[0-9]+}}, {{x[0-9]+}}, [sp, #8]
356356 ; CHECK-APPLE: str {{x[0-9]+}}, [sp]
357357
358 ; CHECK-APPLE: mov x19, xzr
358 ; CHECK-APPLE: mov x21, xzr
359359 ; CHECK-APPLE: bl {{.*}}foo_vararg
360 ; CHECK-APPLE: cbnz x19
360 ; CHECK-APPLE: cbnz x21
361361 ; Access part of the error object and save it to error_ref
362 ; CHECK-APPLE: ldrb [[CODE:w[0-9]+]], [x19, #8]
362 ; CHECK-APPLE: ldrb [[CODE:w[0-9]+]], [x21, #8]
363363 ; CHECK-APPLE: strb [[CODE]], [{{.*}}[[ID]]]
364 ; CHECK-APPLE: mov x0, x19
364 ; CHECK-APPLE: mov x0, x21
365365 ; CHECK-APPLE: bl {{.*}}free
366366 entry:
367367 %error_ptr_ref = alloca swifterror %swift_error*
406406 }
407407
408408 ; CHECK-APPLE-LABEL: swifterror_clobber
409 ; CHECK-APPLE: mov [[REG:x[0-9]+]], x19
409 ; CHECK-APPLE: mov [[REG:x[0-9]+]], x21
410410 ; CHECK-APPLE: nop
411 ; CHECK-APPLE: mov x19, [[REG]]
411 ; CHECK-APPLE: mov x21, [[REG]]
412412 define swiftcc void @swifterror_clobber(%swift_error** nocapture swifterror %err) {
413 call void asm sideeffect "nop", "~{x19}"()
413 call void asm sideeffect "nop", "~{x21}"()
414414 ret void
415415 }
416416
417417 ; CHECK-APPLE-LABEL: swifterror_reg_clobber
418 ; CHECK-APPLE: stp {{.*}}x19
418 ; CHECK-APPLE: stp {{.*}}x21
419419 ; CHECK-APPLE: nop
420 ; CHECK-APPLE: ldp {{.*}}x19
420 ; CHECK-APPLE: ldp {{.*}}x21
421421 define swiftcc void @swifterror_reg_clobber(%swift_error** nocapture %err) {
422 call void asm sideeffect "nop", "~{x19}"()
422 call void asm sideeffect "nop", "~{x21}"()
423423 ret void
424424 }
425425 ; CHECK-APPLE-LABEL: params_in_reg
426426 ; Save callee saved registers and swifterror since it will be clobbered by the first call to params_in_reg2.
427 ; CHECK-APPLE: stp x19, x28, [sp
427 ; CHECK-APPLE: stp x21, x28, [sp
428428 ; CHECK-APPLE: stp x27, x26, [sp
429429 ; CHECK-APPLE: stp x25, x24, [sp
430430 ; CHECK-APPLE: stp x23, x22, [sp
431 ; CHECK-APPLE: stp x21, x20, [sp
431 ; CHECK-APPLE: stp x20, x19, [sp
432432 ; CHECK-APPLE: stp x29, x30, [sp
433433 ; CHECK-APPLE: str x20, [sp
434434 ; Store argument registers.
438438 ; CHECK-APPLE: mov x26, x4
439439 ; CHECK-APPLE: mov x27, x3
440440 ; CHECK-APPLE: mov x28, x2
441 ; CHECK-APPLE: mov x21, x1
441 ; CHECK-APPLE: mov x19, x1
442442 ; CHECK-APPLE: mov x22, x0
443443 ; Setup call.
444444 ; CHECK-APPLE: orr w0, wzr, #0x1
450450 ; CHECK-APPLE: orr w6, wzr, #0x7
451451 ; CHECK-APPLE: orr w7, wzr, #0x8
452452 ; CHECK-APPLE: mov x20, xzr
453 ; CHECK-APPLE: mov x19, xzr
453 ; CHECK-APPLE: mov x21, xzr
454454 ; CHECK-APPLE: bl _params_in_reg2
455455 ; Restore original arguments for next call.
456456 ; CHECK-APPLE: mov x0, x22
457 ; CHECK-APPLE: mov x1, x21
457 ; CHECK-APPLE: mov x1, x19
458458 ; CHECK-APPLE: mov x2, x28
459459 ; CHECK-APPLE: mov x3, x27
460460 ; CHECK-APPLE: mov x4, x26
462462 ; CHECK-APPLE: mov x6, x24
463463 ; CHECK-APPLE: mov x7, x23
464464 ; Restore original swiftself argument and swifterror %err.
465 ; CHECK-APPLE: ldp x20, x19, [sp
465 ; CHECK-APPLE: ldp x20, x21, [sp
466466 ; CHECK-APPLE: bl _params_in_reg2
467 ; Restore calle save registers but don't clober swifterror x19.
468 ; CHECK-APPLE-NOT: x19
467 ; Restore calle save registers but don't clober swifterror x21.
468 ; CHECK-APPLE-NOT: x21
469469 ; CHECK-APPLE: ldp x29, x30, [sp
470 ; CHECK-APPLE-NOT: x19
471 ; CHECK-APPLE: ldp x21, x20, [sp
472 ; CHECK-APPLE-NOT: x19
470 ; CHECK-APPLE-NOT: x21
471 ; CHECK-APPLE: ldp x20, x19, [sp
472 ; CHECK-APPLE-NOT: x21
473473 ; CHECK-APPLE: ldp x23, x22, [sp
474 ; CHECK-APPLE-NOT: x19
474 ; CHECK-APPLE-NOT: x21
475475 ; CHECK-APPLE: ldp x25, x24, [sp
476 ; CHECK-APPLE-NOT: x19
476 ; CHECK-APPLE-NOT: x21
477477 ; CHECK-APPLE: ldp x27, x26, [sp
478 ; CHECK-APPLE-NOT: x19
478 ; CHECK-APPLE-NOT: x21
479479 ; CHECK-APPLE: ldr x28, [sp
480 ; CHECK-APPLE-NOT: x19
480 ; CHECK-APPLE-NOT: x21
481481 ; CHECK-APPLE: ret
482482 define swiftcc void @params_in_reg(i64, i64, i64, i64, i64, i64, i64, i64, i8* swiftself, %swift_error** nocapture swifterror %err) {
483483 %error_ptr_ref = alloca swifterror %swift_error*, align 8
494494 ; CHECK-APPLE: stp x27, x26, [sp
495495 ; CHECK-APPLE: stp x25, x24, [sp
496496 ; CHECK-APPLE: stp x23, x22, [sp
497 ; CHECK-APPLE: stp x21, x20, [sp
497 ; CHECK-APPLE: stp x20, x19, [sp
498498 ; CHECK-APPLE: stp x29, x30, [sp
499499 ; Save original arguments.
500 ; CHECK-APPLE: mov x23, x19
500 ; CHECK-APPLE: mov x23, x21
501501 ; CHECK-APPLE: str x7, [sp, #16]
502502 ; CHECK-APPLE: mov x24, x6
503503 ; CHECK-APPLE: mov x25, x5
504504 ; CHECK-APPLE: mov x26, x4
505505 ; CHECK-APPLE: mov x27, x3
506506 ; CHECK-APPLE: mov x28, x2
507 ; CHECK-APPLE: mov x21, x1
507 ; CHECK-APPLE: mov x19, x1
508508 ; CHECK-APPLE: mov x22, x0
509509 ; Setup call arguments.
510510 ; CHECK-APPLE: orr w0, wzr, #0x1
516516 ; CHECK-APPLE: orr w6, wzr, #0x7
517517 ; CHECK-APPLE: orr w7, wzr, #0x8
518518 ; CHECK-APPLE: mov x20, xzr
519 ; CHECK-APPLE: mov x19, xzr
519 ; CHECK-APPLE: mov x21, xzr
520520 ; CHECK-APPLE: bl _params_in_reg2
521521 ; Store swifterror %error_ptr_ref.
522 ; CHECK-APPLE: str x19, [sp, #8]
522 ; CHECK-APPLE: str x21, [sp, #8]
523523 ; Setup call arguments from original arguments.
524524 ; CHECK-APPLE: mov x0, x22
525 ; CHECK-APPLE: mov x1, x21
525 ; CHECK-APPLE: mov x1, x19
526526 ; CHECK-APPLE: mov x2, x28
527527 ; CHECK-APPLE: mov x3, x27
528528 ; CHECK-APPLE: mov x4, x26
529529 ; CHECK-APPLE: mov x5, x25
530530 ; CHECK-APPLE: mov x6, x24
531531 ; CHECK-APPLE: ldp x7, x20, [sp, #16]
532 ; CHECK-APPLE: mov x19, x23
532 ; CHECK-APPLE: mov x21, x23
533533 ; CHECK-APPLE: bl _params_and_return_in_reg2
534534 ; Store return values.
535 ; CHECK-APPLE: mov x21, x0
535 ; CHECK-APPLE: mov x19, x0
536536 ; CHECK-APPLE: mov x22, x1
537537 ; CHECK-APPLE: mov x24, x2
538538 ; CHECK-APPLE: mov x25, x3
541541 ; CHECK-APPLE: mov x28, x6
542542 ; CHECK-APPLE: mov x23, x7
543543 ; Save swifterror %err.
544 ; CHECK-APPLE: str x19, [sp, #24]
544 ; CHECK-APPLE: str x21, [sp, #24]
545545 ; Setup call.
546546 ; CHECK-APPLE: orr w0, wzr, #0x1
547547 ; CHECK-APPLE: orr w1, wzr, #0x2
553553 ; CHECK-APPLE: orr w7, wzr, #0x8
554554 ; CHECK-APPLE: mov x20, xzr
555555 ; ... setup call with swiferror %error_ptr_ref.
556 ; CHECK-APPLE: ldr x19, [sp, #8]
556 ; CHECK-APPLE: ldr x21, [sp, #8]
557557 ; CHECK-APPLE: bl _params_in_reg2
558558 ; Restore return values for return from this function.
559 ; CHECK-APPLE: mov x0, x21
559 ; CHECK-APPLE: mov x0, x19
560560 ; CHECK-APPLE: mov x1, x22
561561 ; CHECK-APPLE: mov x2, x24
562562 ; CHECK-APPLE: mov x3, x25
565565 ; CHECK-APPLE: mov x6, x28
566566 ; CHECK-APPLE: mov x7, x23
567567 ; Restore swifterror %err and callee save registers.
568 ; CHECK-APPLE: ldp x19, x28, [sp, #24
568 ; CHECK-APPLE: ldp x21, x28, [sp, #24
569569 ; CHECK-APPLE: ldp x29, x30, [sp
570 ; CHECK-APPLE: ldp x21, x20, [sp
570 ; CHECK-APPLE: ldp x20, x19, [sp
571571 ; CHECK-APPLE: ldp x23, x22, [sp
572572 ; CHECK-APPLE: ldp x25, x24, [sp
573573 ; CHECK-APPLE: ldp x27, x26, [sp
1212 ; CHECK-APPLE: mov r0, #16
1313 ; CHECK-APPLE: malloc
1414 ; CHECK-APPLE-DAG: mov [[ID:r[0-9]+]], #1
15 ; CHECK-APPLE-DAG: mov r6, r{{.*}}
15 ; CHECK-APPLE-DAG: mov r8, r{{.*}}
1616 ; CHECK-APPLE-DAG: strb [[ID]], [r{{.*}}, #8]
1717
1818 ; CHECK-O0-LABEL: foo:
2121 ; CHECK-O0: mov [[ID2:r[0-9]+]], r0
2222 ; CHECK-O0: mov [[ID:r[0-9]+]], #1
2323 ; CHECK-O0: strb [[ID]], [r0, #8]
24 ; CHECK-O0: mov r6, [[ID2]]
24 ; CHECK-O0: mov r8, [[ID2]]
2525 entry:
2626 %call = call i8* @malloc(i64 16)
2727 %call.0 = bitcast i8* %call to %swift_error*
3535 define float @caller(i8* %error_ref) {
3636 ; CHECK-APPLE-LABEL: caller:
3737 ; CHECK-APPLE-DAG: mov [[ID:r[0-9]+]], r0
38 ; CHECK-APPLE-DAG: mov r6, #0
38 ; CHECK-APPLE-DAG: mov r8, #0
3939 ; CHECK-APPLE: bl {{.*}}foo
40 ; CHECK-APPLE: cmp r6, #0
40 ; CHECK-APPLE: cmp r8, #0
4141 ; Access part of the error object and save it to error_ref
42 ; CHECK-APPLE: ldrbeq [[CODE:r[0-9]+]], [r6, #8]
42 ; CHECK-APPLE: ldrbeq [[CODE:r[0-9]+]], [r8, #8]
4343 ; CHECK-APPLE: strbeq [[CODE]], [{{.*}}[[ID]]]
44 ; CHECK-APPLE: mov r0, r6
44 ; CHECK-APPLE: mov r0, r8
4545 ; CHECK-APPLE: bl {{.*}}free
4646
4747 ; CHECK-O0-LABEL: caller:
4848 ; spill r0
49 ; CHECK-O0-DAG: mov r6, #0
49 ; CHECK-O0-DAG: mov r8, #0
5050 ; CHECK-O0-DAG: str r0, [sp, [[SLOT:#[0-9]+]]
5151 ; CHECK-O0: bl {{.*}}foo
52 ; CHECK-O0: mov [[TMP:r[0-9]+]], r6
52 ; CHECK-O0: mov [[TMP:r[0-9]+]], r8
5353 ; CHECK-O0: str [[TMP]], [sp]
5454 ; CHECK-O0: bne
5555 ; CHECK-O0: ldrb [[CODE:r[0-9]+]], [r0, #8]
8080 define float @caller2(i8* %error_ref) {
8181 ; CHECK-APPLE-LABEL: caller2:
8282 ; CHECK-APPLE-DAG: mov [[ID:r[0-9]+]], r0
83 ; CHECK-APPLE-DAG: mov r6, #0
83 ; CHECK-APPLE-DAG: mov r8, #0
8484 ; CHECK-APPLE: bl {{.*}}foo
85 ; CHECK-APPLE: cmp r6, #0
85 ; CHECK-APPLE: cmp r8, #0
8686 ; CHECK-APPLE: bne
8787 ; Access part of the error object and save it to error_ref
88 ; CHECK-APPLE: ldrb [[CODE:r[0-9]+]], [r6, #8]
88 ; CHECK-APPLE: ldrb [[CODE:r[0-9]+]], [r8, #8]
8989 ; CHECK-APPLE: strb [[CODE]], [{{.*}}[[ID]]]
90 ; CHECK-APPLE: mov r0, r6
90 ; CHECK-APPLE: mov r0, r8
9191 ; CHECK-APPLE: bl {{.*}}free
9292
9393 ; CHECK-O0-LABEL: caller2:
9494 ; spill r0
9595 ; CHECK-O0-DAG: str r0,
96 ; CHECK-O0-DAG: mov r6, #0
96 ; CHECK-O0-DAG: mov r8, #0
9797 ; CHECK-O0: bl {{.*}}foo
98 ; CHECK-O0: mov r{{.*}}, r6
98 ; CHECK-O0: mov r{{.*}}, r8
9999 ; CHECK-O0: str r0, [sp]
100100 ; CHECK-O0: bne
101101 ; CHECK-O0: ble
137137 ; CHECK-APPLE: mov r0, #16
138138 ; CHECK-APPLE: malloc
139139 ; CHECK-APPLE: mov [[ID:r[0-9]+]], #1
140 ; CHECK-APPLE-DAG: mov r6, r{{.*}}
140 ; CHECK-APPLE-DAG: mov r8, r{{.*}}
141141 ; CHECK-APPLE-DAG: strb [[ID]], [r{{.*}}, #8]
142142
143143 ; CHECK-O0-LABEL: foo_if:
144144 ; CHECK-O0: cmp r0, #0
145145 ; spill to stack
146 ; CHECK-O0: str r6
146 ; CHECK-O0: str r8
147147 ; CHECK-O0: beq
148148 ; CHECK-O0: mov r0, #16
149149 ; CHECK-O0: malloc
150150 ; CHECK-O0: mov [[ID:r[0-9]+]], r0
151151 ; CHECK-O0: mov [[ID2:[a-z0-9]+]], #1
152152 ; CHECK-O0: strb [[ID2]], [r0, #8]
153 ; CHECK-O0: mov r6, [[ID]]
153 ; CHECK-O0: mov r8, [[ID]]
154154 ; reload from stack
155 ; CHECK-O0: ldr r6
155 ; CHECK-O0: ldr r8
156156 entry:
157157 %cond = icmp ne i32 %cc, 0
158158 br i1 %cond, label %gen_error, label %normal
175175 ; CHECK-APPLE-LABEL: foo_loop:
176176 ; CHECK-APPLE: mov [[CODE:r[0-9]+]], r0
177177 ; swifterror is kept in a register
178 ; CHECK-APPLE: mov [[ID:r[0-9]+]], r6
178 ; CHECK-APPLE: mov [[ID:r[0-9]+]], r8
179179 ; CHECK-APPLE: cmp [[CODE]], #0
180180 ; CHECK-APPLE: beq
181181 ; CHECK-APPLE: mov r0, #16
182182 ; CHECK-APPLE: malloc
183183 ; CHECK-APPLE: strb r{{.*}}, [{{.*}}[[ID]], #8]
184184 ; CHECK-APPLE: ble
185 ; CHECK-APPLE: mov r6, [[ID]]
185 ; CHECK-APPLE: mov r8, [[ID]]
186186
187187 ; CHECK-O0-LABEL: foo_loop:
188 ; CHECK-O0: mov r{{.*}}, r6
188 ; CHECK-O0: mov r{{.*}}, r8
189189 ; CHECK-O0: cmp r{{.*}}, #0
190190 ; CHECK-O0: beq
191191 ; CHECK-O0-DAG: movw r{{.*}}, #1
199199 ; CHECK-O0: vcmpe
200200 ; CHECK-O0: ble
201201 ; reload from stack
202 ; CHECK-O0: ldr r6
202 ; CHECK-O0: ldr r8
203203 entry:
204204 br label %bb_loop
205205
230230 ; CHECK-APPLE: mov r0, #16
231231 ; CHECK-APPLE: malloc
232232 ; CHECK-APPLE: mov [[REG:r[0-9]+]], #1
233 ; CHECK-APPLE-DAG: mov r6, r0
233 ; CHECK-APPLE-DAG: mov r8, r0
234234 ; CHECK-APPLE-DAG: strb [[REG]], [r0, #8]
235235 ; CHECK-APPLE-DAG: str r{{.*}}, [{{.*}}[[SRET]], #4]
236236
246246 ; CHECK-O0: ldr
247247 ; CHECK-O0: ldr
248248 ; CHECK-O0: str r{{.*}}, [{{.*}}, #4]
249 ; CHECK-O0: mov r6
249 ; CHECK-O0: mov r8
250250 entry:
251251 %call = call i8* @malloc(i64 16)
252252 %call.0 = bitcast i8* %call to %swift_error*
262262 define float @caller3(i8* %error_ref) {
263263 ; CHECK-APPLE-LABEL: caller3:
264264 ; CHECK-APPLE: mov [[ID:r[0-9]+]], r0
265 ; CHECK-APPLE: mov r6, #0
265 ; CHECK-APPLE: mov r8, #0
266266 ; CHECK-APPLE: bl {{.*}}foo_sret
267 ; CHECK-APPLE: cmp r6, #0
267 ; CHECK-APPLE: cmp r8, #0
268268 ; Access part of the error object and save it to error_ref
269 ; CHECK-APPLE: ldrbeq [[CODE:r[0-9]+]], [r6, #8]
269 ; CHECK-APPLE: ldrbeq [[CODE:r[0-9]+]], [r8, #8]
270270 ; CHECK-APPLE: strbeq [[CODE]], [{{.*}}[[ID]]]
271 ; CHECK-APPLE: mov r0, r6
271 ; CHECK-APPLE: mov r0, r8
272272 ; CHECK-APPLE: bl {{.*}}free
273273
274274 ; CHECK-O0-LABEL: caller3:
275 ; CHECK-O0-DAG: mov r6, #0
275 ; CHECK-O0-DAG: mov r8, #0
276276 ; CHECK-O0-DAG: mov r0
277277 ; CHECK-O0-DAG: mov r1
278278 ; CHECK-O0: bl {{.*}}foo_sret
279 ; CHECK-O0: mov [[ID2:r[0-9]+]], r6
280 ; CHECK-O0: cmp r6
279 ; CHECK-O0: mov [[ID2:r[0-9]+]], r8
280 ; CHECK-O0: cmp r8
281281 ; CHECK-O0: str [[ID2]], [sp[[SLOT:.*]]]
282282 ; CHECK-O0: bne
283283 ; Access part of the error object and save it to error_ref
315315 ; CHECK-APPLE: mov [[REG:r[0-9]+]], r0
316316 ; CHECK-APPLE: mov [[ID:r[0-9]+]], #1
317317 ; CHECK-APPLE-DAG: strb [[ID]], [{{.*}}[[REG]], #8]
318 ; CHECK-APPLE-DAG: mov r6, [[REG]]
318 ; CHECK-APPLE-DAG: mov r8, [[REG]]
319319
320320 entry:
321321 %call = call i8* @malloc(i64 16)
344344 define float @caller4(i8* %error_ref) {
345345 ; CHECK-APPLE-LABEL: caller4:
346346 ; CHECK-APPLE: mov [[ID:r[0-9]+]], r0
347 ; CHECK-APPLE: mov r6, #0
347 ; CHECK-APPLE: mov r8, #0
348348 ; CHECK-APPLE: bl {{.*}}foo_vararg
349 ; CHECK-APPLE: cmp r6, #0
349 ; CHECK-APPLE: cmp r8, #0
350350 ; Access part of the error object and save it to error_ref
351 ; CHECK-APPLE: ldrbeq [[CODE:r[0-9]+]], [r6, #8]
351 ; CHECK-APPLE: ldrbeq [[CODE:r[0-9]+]], [r8, #8]
352352 ; CHECK-APPLE: strbeq [[CODE]], [{{.*}}[[ID]]]
353 ; CHECK-APPLE: mov r0, r6
353 ; CHECK-APPLE: mov r0, r8
354354 ; CHECK-APPLE: bl {{.*}}free
355355 entry:
356356 %error_ptr_ref = alloca swifterror %swift_error*
395395 }
396396
397397 ; CHECK-APPLE-LABEL: swifterror_clobber
398 ; CHECK-APPLE: mov [[REG:r[0-9]+]], r6
398 ; CHECK-APPLE: mov [[REG:r[0-9]+]], r8
399399 ; CHECK-APPLE: nop
400 ; CHECK-APPLE: mov r6, [[REG]]
400 ; CHECK-APPLE: mov r8, [[REG]]
401401 define swiftcc void @swifterror_clobber(%swift_error** nocapture swifterror %err) {
402 call void asm sideeffect "nop", "~{r6}"()
402 call void asm sideeffect "nop", "~{r8}"()
403403 ret void
404404 }
405405
406406 ; CHECK-APPLE-LABEL: swifterror_reg_clobber
407 ; CHECK-APPLE: push {{.*}}r6
407 ; CHECK-APPLE: push {{.*}}r8
408408 ; CHECK-APPLE: nop
409 ; CHECK-APPLE: pop {{.*}}r6
409 ; CHECK-APPLE: pop {{.*}}r8
410410 define swiftcc void @swifterror_reg_clobber(%swift_error** nocapture %err) {
411 call void asm sideeffect "nop", "~{r6}"()
411 call void asm sideeffect "nop", "~{r8}"()
412412 ret void
413413 }
414414
415415 ; CHECK-ARMV7-LABEL: _params_in_reg
416416 ; Store callee saved registers excluding swifterror.
417 ; CHECK-ARMV7: push {r4, r5, r7, r8, r10, r11, lr}
418 ; Store swiftself (r10) and swifterror (r6).
419 ; CHECK-ARMV7-DAG: str r6, [s[[STK1:.*]]]
417 ; CHECK-ARMV7: push {r4, r5, r6, r7, r10, r11, lr}
418 ; Store swiftself (r10) and swifterror (r8).
419 ; CHECK-ARMV7-DAG: str r8, [s[[STK1:.*]]]
420420 ; CHECK-ARMV7-DAG: str r10, [s[[STK2:.*]]]
421421 ; Store arguments.
422 ; CHECK-ARMV7: mov r4, r3
423 ; CHECK-ARMV7: mov r5, r2
424 ; CHECK-ARMV7: mov r8, r1
425 ; CHECK-ARMV7: mov r11, r0
422 ; CHECK-ARMV7: mov r6, r3
423 ; CHECK-ARMV7: mov r4, r2
424 ; CHECK-ARMV7: mov r11, r1
425 ; CHECK-ARMV7: mov r5, r0
426426 ; Setup call.
427427 ; CHECK-ARMV7: mov r0, #1
428428 ; CHECK-ARMV7: mov r1, #2
429429 ; CHECK-ARMV7: mov r2, #3
430430 ; CHECK-ARMV7: mov r3, #4
431431 ; CHECK-ARMV7: mov r10, #0
432 ; CHECK-ARMV7: mov r6, #0
432 ; CHECK-ARMV7: mov r8, #0
433433 ; CHECK-ARMV7: bl _params_in_reg2
434434 ; Restore original arguments.
435435 ; CHECK-ARMV7-DAG: ldr r10, [s[[STK2]]]
436 ; CHECK-ARMV7-DAG: ldr r6, [s[[STK1]]]
437 ; CHECK-ARMV7: mov r0, r11
438 ; CHECK-ARMV7: mov r1, r8
439 ; CHECK-ARMV7: mov r2, r5
440 ; CHECK-ARMV7: mov r3, r4
436 ; CHECK-ARMV7-DAG: ldr r8, [s[[STK1]]]
437 ; CHECK-ARMV7: mov r0, r5
438 ; CHECK-ARMV7: mov r1, r11
439 ; CHECK-ARMV7: mov r2, r4
440 ; CHECK-ARMV7: mov r3, r6
441441 ; CHECK-ARMV7: bl _params_in_reg2
442 ; CHECK-ARMV7: pop {r4, r5, r7, r8, r10, r11, pc}
442 ; CHECK-ARMV7: pop {r4, r5, r6, r7, r10, r11, pc}
443443 define swiftcc void @params_in_reg(i32, i32, i32, i32, i8* swiftself, %swift_error** nocapture swifterror %err) {
444444 %error_ptr_ref = alloca swifterror %swift_error*, align 8
445445 store %swift_error* null, %swift_error** %error_ptr_ref
450450 declare swiftcc void @params_in_reg2(i32, i32, i32, i32, i8* swiftself, %swift_error** nocapture swifterror %err)
451451
452452 ; CHECK-ARMV7-LABEL: params_and_return_in_reg
453 ; CHECK-ARMV7: push {r4, r5, r7, r8, r10, r11, lr}
453 ; CHECK-ARMV7: push {r4, r5, r6, r7, r10, r11, lr}
454454 ; Store swifterror and swiftself
455 ; CHECK-ARMV7: mov r4, r6
455 ; CHECK-ARMV7: mov r6, r8
456456 ; CHECK-ARMV7: str r10, [s[[STK1:.*]]]
457457 ; Store arguments.
458458 ; CHECK-ARMV7: str r3, [s[[STK2:.*]]]
459 ; CHECK-ARMV7: mov r5, r2
460 ; CHECK-ARMV7: mov r8, r1
461 ; CHECK-ARMV7: mov r11, r0
459 ; CHECK-ARMV7: mov r4, r2
460 ; CHECK-ARMV7: mov r11, r1
461 ; CHECK-ARMV7: mov r5, r0
462462 ; Setup call.
463463 ; CHECK-ARMV7: mov r0, #1
464464 ; CHECK-ARMV7: mov r1, #2
465465 ; CHECK-ARMV7: mov r2, #3
466466 ; CHECK-ARMV7: mov r3, #4
467467 ; CHECK-ARMV7: mov r10, #0
468 ; CHECK-ARMV7: mov r6, #0
468 ; CHECK-ARMV7: mov r8, #0
469469 ; CHECK-ARMV7: bl _params_in_reg2
470470 ; Restore original arguments.
471471 ; CHECK-ARMV7: ldr r3, [s[[STK2]]]
472472 ; CHECK-ARMV7: ldr r10, [s[[STK1]]]
473473 ; Store %error_ptr_ref;
474 ; CHECK-ARMV7: str r6, [s[[STK3:.*]]]
474 ; CHECK-ARMV7: str r8, [s[[STK3:.*]]]
475475 ; Restore original arguments.
476 ; CHECK-ARMV7: mov r0, r11
477 ; CHECK-ARMV7: mov r1, r8
478 ; CHECK-ARMV7: mov r2, r5
479 ; CHECK-ARMV7: mov r6, r4
476 ; CHECK-ARMV7: mov r0, r5
477 ; CHECK-ARMV7: mov r1, r11
478 ; CHECK-ARMV7: mov r2, r4
479 ; CHECK-ARMV7: mov r8, r6
480480 ; CHECK-ARMV7: bl _params_and_return_in_reg2
481481 ; Store swifterror return %err;
482 ; CHECK-ARMV7: str r6, [s[[STK1]]]
482 ; CHECK-ARMV7: str r8, [s[[STK1]]]
483483 ; Load swifterror value %error_ptr_ref.
484 ; CHECK-ARMV7: ldr r6, [s[[STK3]]]
484 ; CHECK-ARMV7: ldr r8, [s[[STK3]]]
485485 ; Save return values.
486 ; CHECK-ARMV7: mov r5, r0
487 ; CHECK-ARMV7: mov r4, r1
488 ; CHECK-ARMV7: mov r8, r2
486 ; CHECK-ARMV7: mov r4, r0
487 ; CHECK-ARMV7: mov r5, r1
488 ; CHECK-ARMV7: mov r6, r2
489489 ; CHECK-ARMV7: mov r11, r3
490490 ; Setup call.
491491 ; CHECK-ARMV7: mov r0, #1
495495 ; CHECK-ARMV7: mov r10, #0
496496 ; CHECK-ARMV7: bl _params_in_reg2
497497 ; Load swifterror %err;
498 ; CHECK-ARMV7: ldr r6, [s[[STK1]]]
498 ; CHECK-ARMV7: ldr r8, [s[[STK1]]]
499499 ; Restore return values for returning.
500 ; CHECK-ARMV7: mov r0, r5
501 ; CHECK-ARMV7: mov r1, r4
502 ; CHECK-ARMV7: mov r2, r8
500 ; CHECK-ARMV7: mov r0, r4
501 ; CHECK-ARMV7: mov r1, r5
502 ; CHECK-ARMV7: mov r2, r6
503503 ; CHECK-ARMV7: mov r3, r11
504 ; CHECK-ARMV7: pop {r4, r5, r7, r8, r10, r11, pc}
504 ; CHECK-ARMV7: pop {r4, r5, r6, r7, r10, r11, pc}
505505 define swiftcc { i32, i32, i32, i32} @params_and_return_in_reg(i32, i32, i32, i32, i8* swiftself, %swift_error** nocapture swifterror %err) {
506506 %error_ptr_ref = alloca swifterror %swift_error*, align 8
507507 store %swift_error* null, %swift_error** %error_ptr_ref