Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 1 | ; RUN: llc -verify-machineinstrs < %s -mtriple=aarch64-none-linux-gnu -tailcallopt | FileCheck %s |
Tim Northover | e0e3aef | 2013-01-31 12:12:40 +0000 | [diff] [blame] | 2 | |
| 3 | ; This test is designed to be run in the situation where the |
| 4 | ; call-frame is not reserved (hence disable-fp-elim), but where |
| 5 | ; callee-pop can occur (hence tailcallopt). |
| 6 | |
| 7 | declare fastcc void @will_pop([8 x i32], i32 %val) |
| 8 | |
| 9 | define fastcc void @foo(i32 %in) { |
Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 10 | ; CHECK-LABEL: foo: |
Tim Northover | e0e3aef | 2013-01-31 12:12:40 +0000 | [diff] [blame] | 11 | |
| 12 | %addr = alloca i8, i32 %in |
| 13 | |
| 14 | ; Normal frame setup stuff: |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 15 | ; CHECK: stp x29, x30, [sp, #-16]! |
| 16 | ; CHECK: mov x29, sp |
Tim Northover | e0e3aef | 2013-01-31 12:12:40 +0000 | [diff] [blame] | 17 | |
| 18 | ; Reserve space for call-frame: |
Chad Rosier | 11c825f | 2015-09-30 19:44:40 +0000 | [diff] [blame^] | 19 | ; CHECK: str w{{[0-9]+}}, [sp, #-16]! |
Tim Northover | e0e3aef | 2013-01-31 12:12:40 +0000 | [diff] [blame] | 20 | |
| 21 | call fastcc void @will_pop([8 x i32] undef, i32 42) |
| 22 | ; CHECK: bl will_pop |
| 23 | |
| 24 | ; Since @will_pop is fastcc with tailcallopt, it will put the stack |
| 25 | ; back where it needs to be, we shouldn't duplicate that |
| 26 | ; CHECK-NOT: sub sp, sp, #16 |
| 27 | ; CHECK-NOT: add sp, sp, |
| 28 | |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 29 | ; CHECK: mov sp, x29 |
| 30 | ; CHECK: ldp x29, x30, [sp], #16 |
Tim Northover | e0e3aef | 2013-01-31 12:12:40 +0000 | [diff] [blame] | 31 | ret void |
| 32 | } |
| 33 | |
| 34 | declare void @wont_pop([8 x i32], i32 %val) |
| 35 | |
| 36 | define void @foo1(i32 %in) { |
Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 37 | ; CHECK-LABEL: foo1: |
Tim Northover | e0e3aef | 2013-01-31 12:12:40 +0000 | [diff] [blame] | 38 | |
| 39 | %addr = alloca i8, i32 %in |
| 40 | ; Normal frame setup again |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 41 | ; CHECK: stp x29, x30, [sp, #-16]! |
| 42 | ; CHECK: mov x29, sp |
Tim Northover | e0e3aef | 2013-01-31 12:12:40 +0000 | [diff] [blame] | 43 | |
| 44 | ; Reserve space for call-frame |
Chad Rosier | 11c825f | 2015-09-30 19:44:40 +0000 | [diff] [blame^] | 45 | ; CHECK: str w{{[0-9]+}}, [sp, #-16]! |
Tim Northover | e0e3aef | 2013-01-31 12:12:40 +0000 | [diff] [blame] | 46 | |
| 47 | call void @wont_pop([8 x i32] undef, i32 42) |
Benjamin Kramer | 01b75cc | 2013-03-09 18:25:40 +0000 | [diff] [blame] | 48 | ; CHECK: bl wont_pop |
Tim Northover | e0e3aef | 2013-01-31 12:12:40 +0000 | [diff] [blame] | 49 | |
| 50 | ; This time we *do* need to unreserve the call-frame |
Benjamin Kramer | 01b75cc | 2013-03-09 18:25:40 +0000 | [diff] [blame] | 51 | ; CHECK: add sp, sp, #16 |
Tim Northover | e0e3aef | 2013-01-31 12:12:40 +0000 | [diff] [blame] | 52 | |
| 53 | ; Check for epilogue (primarily to make sure sp spotted above wasn't |
| 54 | ; part of it). |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 55 | ; CHECK: mov sp, x29 |
| 56 | ; CHECK: ldp x29, x30, [sp], #16 |
Tim Northover | e0e3aef | 2013-01-31 12:12:40 +0000 | [diff] [blame] | 57 | ret void |
| 58 | } |