Mercurial > hg > Members > tobaru > cbc > CbC_llvm
comparison test/CodeGen/AArch64/tail-call.ll @ 77:54457678186b
LLVM 3.6
author | Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 08 Sep 2014 22:06:00 +0900 |
parents | 95c75e76d11b |
children | afa8332a0e37 |
comparison
equal
deleted
inserted
replaced
34:e874dbf0ad9d | 77:54457678186b |
---|---|
1 ; RUN: llc -verify-machineinstrs < %s -mtriple=aarch64-none-linux-gnu -tailcallopt | FileCheck %s | 1 ; RUN: llc -verify-machineinstrs < %s -mtriple=aarch64-none-linux-gnu -tailcallopt | FileCheck %s |
2 | 2 |
3 declare fastcc void @callee_stack0() | 3 declare fastcc void @callee_stack0() |
4 declare fastcc void @callee_stack8([8 x i32], i64) | 4 declare fastcc void @callee_stack8([8 x i32], i64) |
5 declare fastcc void @callee_stack16([8 x i32], i64, i64) | 5 declare fastcc void @callee_stack16([8 x i32], i64, i64) |
6 declare extern_weak fastcc void @callee_weak() | |
6 | 7 |
7 define fastcc void @caller_to0_from0() nounwind { | 8 define fastcc void @caller_to0_from0() nounwind { |
8 ; CHECK-LABEL: caller_to0_from0: | 9 ; CHECK-LABEL: caller_to0_from0: |
9 ; CHECK-NEXT: // BB | 10 ; CHECK-NEXT: // BB |
11 | |
10 tail call fastcc void @callee_stack0() | 12 tail call fastcc void @callee_stack0() |
11 ret void | 13 ret void |
14 | |
12 ; CHECK-NEXT: b callee_stack0 | 15 ; CHECK-NEXT: b callee_stack0 |
13 } | 16 } |
14 | 17 |
15 define fastcc void @caller_to0_from8([8 x i32], i64) { | 18 define fastcc void @caller_to0_from8([8 x i32], i64) { |
16 ; CHECK-LABEL: caller_to0_from8: | 19 ; CHECK-LABEL: caller_to0_from8: |
17 | 20 |
18 tail call fastcc void @callee_stack0() | 21 tail call fastcc void @callee_stack0() |
19 ret void | 22 ret void |
23 | |
20 ; CHECK: add sp, sp, #16 | 24 ; CHECK: add sp, sp, #16 |
21 ; CHECK-NEXT: b callee_stack0 | 25 ; CHECK-NEXT: b callee_stack0 |
22 } | 26 } |
23 | 27 |
24 define fastcc void @caller_to8_from0() { | 28 define fastcc void @caller_to8_from0() { |
27 | 31 |
28 ; Key point is that the "42" should go #16 below incoming stack | 32 ; Key point is that the "42" should go #16 below incoming stack |
29 ; pointer (we didn't have arg space to reuse). | 33 ; pointer (we didn't have arg space to reuse). |
30 tail call fastcc void @callee_stack8([8 x i32] undef, i64 42) | 34 tail call fastcc void @callee_stack8([8 x i32] undef, i64 42) |
31 ret void | 35 ret void |
32 ; CHECK: str {{x[0-9]+}}, [sp, #16] | 36 |
33 ; CHECK-NEXT: add sp, sp, #16 | 37 ; CHECK: str {{x[0-9]+}}, [sp, #16]! |
34 ; CHECK-NEXT: b callee_stack8 | 38 ; CHECK-NEXT: b callee_stack8 |
35 } | 39 } |
36 | 40 |
37 define fastcc void @caller_to8_from8([8 x i32], i64 %a) { | 41 define fastcc void @caller_to8_from8([8 x i32], i64 %a) { |
38 ; CHECK-LABEL: caller_to8_from8: | 42 ; CHECK-LABEL: caller_to8_from8: |
39 ; CHECK: sub sp, sp, #16 | 43 ; CHECK: sub sp, sp, #16 |
40 | 44 |
41 ; Key point is that the "%a" should go where at SP on entry. | 45 ; Key point is that the "%a" should go where at SP on entry. |
42 tail call fastcc void @callee_stack8([8 x i32] undef, i64 42) | 46 tail call fastcc void @callee_stack8([8 x i32] undef, i64 42) |
43 ret void | 47 ret void |
44 ; CHECK: str {{x[0-9]+}}, [sp, #16] | 48 |
45 ; CHECK-NEXT: add sp, sp, #16 | 49 ; CHECK: str {{x[0-9]+}}, [sp, #16]! |
46 ; CHECK-NEXT: b callee_stack8 | 50 ; CHECK-NEXT: b callee_stack8 |
47 } | 51 } |
48 | 52 |
49 define fastcc void @caller_to16_from8([8 x i32], i64 %a) { | 53 define fastcc void @caller_to16_from8([8 x i32], i64 %a) { |
50 ; CHECK-LABEL: caller_to16_from8: | 54 ; CHECK-LABEL: caller_to16_from8: |
52 | 56 |
53 ; Important point is that the call reuses the "dead" argument space | 57 ; Important point is that the call reuses the "dead" argument space |
54 ; above %a on the stack. If it tries to go below incoming-SP then the | 58 ; above %a on the stack. If it tries to go below incoming-SP then the |
55 ; callee will not deallocate the space, even in fastcc. | 59 ; callee will not deallocate the space, even in fastcc. |
56 tail call fastcc void @callee_stack16([8 x i32] undef, i64 42, i64 2) | 60 tail call fastcc void @callee_stack16([8 x i32] undef, i64 42, i64 2) |
57 ; CHECK: str {{x[0-9]+}}, [sp, #24] | 61 |
58 ; CHECK: str {{x[0-9]+}}, [sp, #16] | 62 ; CHECK: stp {{x[0-9]+}}, {{x[0-9]+}}, [sp, #16] |
59 ; CHECK: add sp, sp, #16 | 63 ; CHECK-NEXT: add sp, sp, #16 |
60 ; CHECK: b callee_stack16 | 64 ; CHECK-NEXT: b callee_stack16 |
61 ret void | 65 ret void |
62 } | 66 } |
63 | 67 |
64 | 68 |
65 define fastcc void @caller_to8_from24([8 x i32], i64 %a, i64 %b, i64 %c) { | 69 define fastcc void @caller_to8_from24([8 x i32], i64 %a, i64 %b, i64 %c) { |
67 ; CHECK: sub sp, sp, #16 | 71 ; CHECK: sub sp, sp, #16 |
68 | 72 |
69 ; Key point is that the "%a" should go where at #16 above SP on entry. | 73 ; Key point is that the "%a" should go where at #16 above SP on entry. |
70 tail call fastcc void @callee_stack8([8 x i32] undef, i64 42) | 74 tail call fastcc void @callee_stack8([8 x i32] undef, i64 42) |
71 ret void | 75 ret void |
72 ; CHECK: str {{x[0-9]+}}, [sp, #32] | 76 |
73 ; CHECK-NEXT: add sp, sp, #32 | 77 ; CHECK: str {{x[0-9]+}}, [sp, #32]! |
74 ; CHECK-NEXT: b callee_stack8 | 78 ; CHECK-NEXT: b callee_stack8 |
75 } | 79 } |
76 | 80 |
77 | 81 |
78 define fastcc void @caller_to16_from16([8 x i32], i64 %a, i64 %b) { | 82 define fastcc void @caller_to16_from16([8 x i32], i64 %a, i64 %b) { |
82 ; Here we want to make sure that both loads happen before the stores: | 86 ; Here we want to make sure that both loads happen before the stores: |
83 ; otherwise either %a or %b will be wrongly clobbered. | 87 ; otherwise either %a or %b will be wrongly clobbered. |
84 tail call fastcc void @callee_stack16([8 x i32] undef, i64 %b, i64 %a) | 88 tail call fastcc void @callee_stack16([8 x i32] undef, i64 %b, i64 %a) |
85 ret void | 89 ret void |
86 | 90 |
87 ; CHECK: ldr x0, | 91 ; CHECK: ldp {{x[0-9]+}}, {{x[0-9]+}}, [sp, #16] |
88 ; CHECK: ldr x1, | 92 ; CHECK: stp {{x[0-9]+}}, {{x[0-9]+}}, [sp, #16] |
89 ; CHECK: str x1, | 93 ; CHECK-NEXT: add sp, sp, #16 |
90 ; CHECK: str x0, | 94 ; CHECK-NEXT: b callee_stack16 |
95 } | |
91 | 96 |
92 ; CHECK: add sp, sp, #16 | 97 |
93 ; CHECK: b callee_stack16 | 98 ; Weakly-referenced extern functions cannot be tail-called, as AAELF does |
99 ; not define the behaviour of branch instructions to undefined weak symbols. | |
100 define fastcc void @caller_weak() { | |
101 ; CHECK-LABEL: caller_weak: | |
102 ; CHECK: bl callee_weak | |
103 tail call void @callee_weak() | |
104 ret void | |
94 } | 105 } |