1; RUN: llc -verify-machineinstrs < %s -mtriple=aarch64-none-linux-gnu -tailcallopt | FileCheck %s -check-prefix CHECK-TAIL 2; RUN: llc -verify-machineinstrs < %s -mtriple=aarch64-none-linux-gnu | FileCheck %s 3 4; Without tailcallopt fastcc still means the caller cleans up the 5; stack, so try to make sure this is respected. 6 7define fastcc void @func_stack0() { 8; CHECK-LABEL: func_stack0: 9; CHECK: mov x29, sp 10; CHECK-NEXT: sub sp, sp, #32 11 12; CHECK-TAIL-LABEL: func_stack0: 13; CHECK-TAIL: stp x29, x30, [sp, #-16]! 14; CHECK-TAIL-NEXT: mov x29, sp 15; CHECK-TAIL-NEXT: sub sp, sp, #32 16 17 18 call fastcc void @func_stack8([8 x i32] undef, i32 42) 19; CHECK: bl func_stack8 20; CHECK-NOT: sub sp, sp, 21 22; CHECK-TAIL: bl func_stack8 23; CHECK-TAIL: sub sp, sp, #16 24 25 26 call fastcc void @func_stack32([8 x i32] undef, i128 0, i128 9) 27; CHECK: bl func_stack32 28; CHECK-NOT: sub sp, sp, 29 30 31; CHECK-TAIL: bl func_stack32 32; CHECK-TAIL: sub sp, sp, #32 33 34 35 call fastcc void @func_stack0() 36; CHECK: bl func_stack0 37; CHECK-NOT: sub sp, sp 38 39 40; CHECK-TAIL: bl func_stack0 41; CHECK-TAIL-NOT: sub sp, sp 42 43 ret void 44; CHECK: mov sp, x29 45; CHECK-NEXT: ldp x29, x30, [sp], #16 46; CHECK-NEXT: ret 47 48 49; CHECK-TAIL: mov sp, x29 50; CHECK-TAIL-NEXT: ldp x29, x30, [sp], #16 51; CHECK-TAIL-NEXT: ret 52} 53 54define fastcc void @func_stack8([8 x i32], i32 %stacked) { 55; CHECK-LABEL: func_stack8: 56; CHECK: stp x29, x30, [sp, #-16]! 57; CHECK: mov x29, sp 58; CHECK: sub sp, sp, #32 59 60 61; CHECK-TAIL-LABEL: func_stack8: 62; CHECK-TAIL: stp x29, x30, [sp, #-16]! 63; CHECK-TAIL: mov x29, sp 64; CHECK-TAIL: sub sp, sp, #32 65 66 67 call fastcc void @func_stack8([8 x i32] undef, i32 42) 68; CHECK: bl func_stack8 69; CHECK-NOT: sub sp, sp, 70 71 72; CHECK-TAIL: bl func_stack8 73; CHECK-TAIL: sub sp, sp, #16 74 75 76 call fastcc void @func_stack32([8 x i32] undef, i128 0, i128 9) 77; CHECK: bl func_stack32 78; CHECK-NOT: sub sp, sp, 79 80 81; CHECK-TAIL: bl func_stack32 82; CHECK-TAIL: sub sp, sp, #32 83 84 85 call fastcc void @func_stack0() 86; CHECK: bl func_stack0 87; CHECK-NOT: sub sp, sp 88 89; CHECK-TAIL: bl func_stack0 90; CHECK-TAIL-NOT: sub sp, sp 91 92 ret void 93; CHECK: mov sp, x29 94; CHECK-NEXT: ldp x29, x30, [sp], #16 95; CHECK-NEXT: ret 96 97 98; CHECK-TAIL: mov sp, x29 99; CHECK-TAIL-NEXT: ldp x29, x30, [sp], #16 100; CHECK-TAIL-NEXT: ret 101} 102 103define fastcc void @func_stack32([8 x i32], i128 %stacked0, i128 %stacked1) { 104; CHECK-LABEL: func_stack32: 105; CHECK: mov x29, sp 106 107; CHECK-TAIL-LABEL: func_stack32: 108; CHECK-TAIL: mov x29, sp 109 110 111 call fastcc void @func_stack8([8 x i32] undef, i32 42) 112; CHECK: bl func_stack8 113; CHECK-NOT: sub sp, sp, 114 115; CHECK-TAIL: bl func_stack8 116; CHECK-TAIL: sub sp, sp, #16 117 118 119 call fastcc void @func_stack32([8 x i32] undef, i128 0, i128 9) 120; CHECK: bl func_stack32 121; CHECK-NOT: sub sp, sp, 122 123 124; CHECK-TAIL: bl func_stack32 125; CHECK-TAIL: sub sp, sp, #32 126 127 128 call fastcc void @func_stack0() 129; CHECK: bl func_stack0 130; CHECK-NOT: sub sp, sp 131 132 133; CHECK-TAIL: bl func_stack0 134; CHECK-TAIL-NOT: sub sp, sp 135 136 ret void 137; CHECK: mov sp, x29 138; CHECK-NEXT: ldp x29, x30, [sp], #16 139; CHECK-NEXT: ret 140 141; CHECK-TAIL: mov sp, x29 142; CHECK-TAIL-NEXT: ldp x29, x30, [sp], #16 143; CHECK-TAIL-NEXT: ret 144} 145