| ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 |
| ; RUN: llc %s -mtriple=aarch64 -o - | FileCheck %s --check-prefixes=CHECK,SDAG |
| ; RUN: llc %s -mtriple=aarch64 -global-isel -o - | FileCheck %s --check-prefixes=CHECK,GI |
| |
| ; Tail calls which have stack arguments in the same offsets as the caller do not |
| ; need to load and store the arguments from the stack. |
| |
| declare void @func(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e, i32 %f, i32 %g, i32 %h, i32 %i, i32 %j) |
| |
| define void @wrapper_func(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e, i32 %f, i32 %g, i32 %h, i32 %i, i32 %j) { |
| ; CHECK-LABEL: wrapper_func: |
| ; CHECK: // %bb.0: |
| ; CHECK-NEXT: b func |
| |
| tail call void @func(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e, i32 %f, i32 %g, i32 %h, i32 %i, i32 %j) |
| ret void |
| } |
| |
| define void @wrapper_func_zero_arg(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e, i32 %f, i32 %g, i32 %h, i32 %i, i32 %j) { |
| ; CHECK-LABEL: wrapper_func_zero_arg: |
| ; CHECK: // %bb.0: |
| ; CHECK-NEXT: str wzr, [sp, #8] |
| ; CHECK-NEXT: b func |
| tail call void @func(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e, i32 %f, i32 %g, i32 %h, i32 %i, i32 0) |
| ret void |
| } |
| |
| define void @wrapper_func_overriden_arg(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e, i32 %f, i32 %g, i32 %h, i32 %i, i32 %j) { |
| ; CHECK-LABEL: wrapper_func_overriden_arg: |
| ; CHECK: // %bb.0: |
| ; CHECK-NEXT: ldr w8, [sp] |
| ; CHECK-NEXT: str wzr, [sp] |
| ; CHECK-NEXT: str w8, [sp, #8] |
| ; CHECK-NEXT: b func |
| tail call void @func(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e, i32 %f, i32 %g, i32 %h, i32 0, i32 %i) |
| ret void |
| } |
| |
| declare void @func_i1(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e, i32 %f, i32 %g, i32 %h, i32 %i, i1 %j) |
| |
| ; FIXME: Support i1 passthrough stack arguments in GlobalISel. |
| define void @wrapper_func_i1(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e, i32 %f, i32 %g, i32 %h, i32 %i, i1 %j) { |
| ; SDAG-LABEL: wrapper_func_i1: |
| ; SDAG: // %bb.0: |
| ; SDAG-NEXT: b func_i1 |
| ; |
| ; GI-LABEL: wrapper_func_i1: |
| ; GI: // %bb.0: |
| ; GI-NEXT: ldrb w8, [sp, #8] |
| ; GI-NEXT: strb w8, [sp, #8] |
| ; GI-NEXT: b func_i1 |
| tail call void @func_i1(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e, i32 %f, i32 %g, i32 %h, i32 %i, i1 %j) |
| ret void |
| } |
| |
| declare void @func_signext_i1(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e, i32 %f, i32 %g, i32 %h, i32 %i, i1 signext %j) |
| |
| ; FIXME: Support zero/sign-extended stack arguments. |
| define void @wrapper_func_i8(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e, i32 %f, i32 %g, i32 %h, i32 %i, i1 signext %j) { |
| ; CHECK-LABEL: wrapper_func_i8: |
| ; CHECK: // %bb.0: |
| ; CHECK-NEXT: ldrsb w8, [sp, #8] |
| ; CHECK-NEXT: strb w8, [sp, #8] |
| ; CHECK-NEXT: b func_signext_i1 |
| tail call void @func_signext_i1(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e, i32 %f, i32 %g, i32 %h, i32 %i, i1 signext %j) |
| ret void |
| } |
| |
| declare void @func_i64(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e, i32 %f, i32 %g, i32 %h, i32 %i, i64 %j) |
| |
| define void @wrapper_func_i64(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e, i32 %f, i32 %g, i32 %h, i32 %i, i32 %j) { |
| ; CHECK-LABEL: wrapper_func_i64: |
| ; CHECK: // %bb.0: |
| ; CHECK-NEXT: ldr w8, [sp, #8] |
| ; CHECK-NEXT: str x8, [sp, #8] |
| ; CHECK-NEXT: b func_i64 |
| %conv = zext i32 %j to i64 |
| tail call void @func_i64(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e, i32 %f, i32 %g, i32 %h, i32 %i, i64 %conv) |
| ret void |
| } |
| |
| ; A musttail call with 9 bytes of stack arg area: the first 8 formal arguments |
| ; land in registers, followed by ptr %8 (8 bytes) and i1 %9 (1 byte) packed |
| ; tightly on the stack without padding. 9 is neither 8 nor 16-byte aligned, so |
| ; we need to round up NumBytes of frame size in order to keep the FPDiff aligned |
| ; for a stack-restoring (tailcc) callee. |
| declare tailcc void @func_9_bytes_argspace(i64, i64, i64, i64, i64, i64, i64, i64, ptr, i1) |
| |
| define tailcc void @wrapper_func_9_bytes_argspace(i64 %0, i64 %1, i64 %2, i64 %3, i64 %4, i64 %5, i64 %6, i64 %7, ptr %8, i1 %9) { |
| ; SDAG-LABEL: wrapper_func_9_bytes_argspace: |
| ; SDAG: // %bb.0: |
| ; SDAG-NEXT: b func_9_bytes_argspace |
| ; |
| ; GI-LABEL: wrapper_func_9_bytes_argspace: |
| ; GI: // %bb.0: |
| ; GI-NEXT: ldrb w8, [sp, #8] |
| ; GI-NEXT: strb w8, [sp, #8] |
| ; GI-NEXT: b func_9_bytes_argspace |
| musttail call tailcc void @func_9_bytes_argspace(i64 %0, i64 %1, i64 %2, i64 %3, i64 %4, i64 %5, i64 %6, i64 %7, ptr %8, i1 %9) |
| ret void |
| } |