Evan Cheng | a6bff98 | 2010-01-30 01:22:00 +0000 | [diff] [blame] | 1 | ; RUN: llc < %s -march=x86 -asm-verbose=false | FileCheck %s -check-prefix=32 |
| 2 | ; RUN: llc < %s -march=x86-64 -asm-verbose=false | FileCheck %s -check-prefix=64 |
Evan Cheng | 8148ae8 | 2010-02-03 21:40:40 +0000 | [diff] [blame^] | 3 | ; XFAIL: * |
Evan Cheng | b171245 | 2010-01-27 06:25:16 +0000 | [diff] [blame] | 4 | |
Evan Cheng | 7096ae4 | 2010-01-29 06:45:59 +0000 | [diff] [blame] | 5 | define void @t1(i32 %x) nounwind ssp { |
Evan Cheng | b171245 | 2010-01-27 06:25:16 +0000 | [diff] [blame] | 6 | entry: |
Evan Cheng | a6bff98 | 2010-01-30 01:22:00 +0000 | [diff] [blame] | 7 | ; 32: t1: |
| 8 | ; 32: jmp {{_?}}foo |
| 9 | |
| 10 | ; 64: t1: |
| 11 | ; 64: jmp {{_?}}foo |
Evan Cheng | b171245 | 2010-01-27 06:25:16 +0000 | [diff] [blame] | 12 | tail call void @foo() nounwind |
| 13 | ret void |
| 14 | } |
| 15 | |
| 16 | declare void @foo() |
Evan Cheng | 7096ae4 | 2010-01-29 06:45:59 +0000 | [diff] [blame] | 17 | |
| 18 | define void @t2() nounwind ssp { |
| 19 | entry: |
Evan Cheng | a6bff98 | 2010-01-30 01:22:00 +0000 | [diff] [blame] | 20 | ; 32: t2: |
| 21 | ; 32: jmp {{_?}}foo2 |
| 22 | |
| 23 | ; 64: t2: |
| 24 | ; 64: jmp {{_?}}foo2 |
Evan Cheng | 7096ae4 | 2010-01-29 06:45:59 +0000 | [diff] [blame] | 25 | %0 = tail call i32 @foo2() nounwind |
| 26 | ret void |
| 27 | } |
| 28 | |
| 29 | declare i32 @foo2() |
| 30 | |
| 31 | define void @t3() nounwind ssp { |
| 32 | entry: |
Evan Cheng | a6bff98 | 2010-01-30 01:22:00 +0000 | [diff] [blame] | 33 | ; 32: t3: |
| 34 | ; 32: jmp {{_?}}foo3 |
| 35 | |
| 36 | ; 64: t3: |
| 37 | ; 64: jmp {{_?}}foo3 |
Evan Cheng | 7096ae4 | 2010-01-29 06:45:59 +0000 | [diff] [blame] | 38 | %0 = tail call i32 @foo3() nounwind |
| 39 | ret void |
| 40 | } |
| 41 | |
| 42 | declare i32 @foo3() |
Evan Cheng | a6bff98 | 2010-01-30 01:22:00 +0000 | [diff] [blame] | 43 | |
| 44 | define void @t4(void (i32)* nocapture %x) nounwind ssp { |
| 45 | entry: |
| 46 | ; 32: t4: |
| 47 | ; 32: call * |
| 48 | ; FIXME: gcc can generate a tailcall for this. But it's tricky. |
| 49 | |
| 50 | ; 64: t4: |
| 51 | ; 64-NOT: call |
| 52 | ; 64: jmpq * |
| 53 | tail call void %x(i32 0) nounwind |
| 54 | ret void |
| 55 | } |
| 56 | |
| 57 | define void @t5(void ()* nocapture %x) nounwind ssp { |
| 58 | entry: |
| 59 | ; 32: t5: |
| 60 | ; 32-NOT: call |
| 61 | ; 32: jmpl * |
| 62 | |
| 63 | ; 64: t5: |
| 64 | ; 64-NOT: call |
| 65 | ; 64: jmpq * |
| 66 | tail call void %x() nounwind |
| 67 | ret void |
| 68 | } |
Evan Cheng | 843bd69 | 2010-01-31 06:44:49 +0000 | [diff] [blame] | 69 | |
| 70 | define i32 @t6(i32 %x) nounwind ssp { |
| 71 | entry: |
| 72 | ; 32: t6: |
| 73 | ; 32: call {{_?}}t6 |
| 74 | ; 32: call {{_?}}bar |
| 75 | |
| 76 | ; 64: t6: |
Evan Cheng | 0a4fd46 | 2010-02-01 02:13:39 +0000 | [diff] [blame] | 77 | ; 64: jmp {{_?}}t6 |
Evan Cheng | 843bd69 | 2010-01-31 06:44:49 +0000 | [diff] [blame] | 78 | ; 64: jmp {{_?}}bar |
| 79 | %0 = icmp slt i32 %x, 10 |
| 80 | br i1 %0, label %bb, label %bb1 |
| 81 | |
| 82 | bb: |
| 83 | %1 = add nsw i32 %x, -1 |
| 84 | %2 = tail call i32 @t6(i32 %1) nounwind ssp |
| 85 | ret i32 %2 |
| 86 | |
| 87 | bb1: |
| 88 | %3 = tail call i32 @bar(i32 %x) nounwind |
| 89 | ret i32 %3 |
| 90 | } |
| 91 | |
| 92 | declare i32 @bar(i32) |
Evan Cheng | b2c9290 | 2010-02-02 02:22:50 +0000 | [diff] [blame] | 93 | |
| 94 | define i32 @t7(i32 %a, i32 %b, i32 %c) nounwind ssp { |
| 95 | entry: |
| 96 | ; 32: t7: |
| 97 | ; 32: jmp {{_?}}bar2 |
| 98 | |
| 99 | ; 64: t7: |
| 100 | ; 64: jmp {{_?}}bar2 |
| 101 | %0 = tail call i32 @bar2(i32 %a, i32 %b, i32 %c) nounwind |
| 102 | ret i32 %0 |
| 103 | } |
| 104 | |
| 105 | declare i32 @bar2(i32, i32, i32) |
Evan Cheng | 86809cc | 2010-02-03 03:28:02 +0000 | [diff] [blame] | 106 | |
| 107 | define signext i16 @t8() nounwind ssp { |
| 108 | entry: |
| 109 | ; 32: t8: |
| 110 | ; 32: jmp {{_?}}bar3 |
| 111 | |
| 112 | ; 64: t8: |
| 113 | ; 64: jmp {{_?}}bar3 |
| 114 | %0 = tail call signext i16 @bar3() nounwind ; <i16> [#uses=1] |
| 115 | ret i16 %0 |
| 116 | } |
| 117 | |
| 118 | declare signext i16 @bar3() |
| 119 | |
| 120 | define signext i16 @t9(i32 (i32)* nocapture %x) nounwind ssp { |
| 121 | entry: |
| 122 | ; 32: t9: |
| 123 | ; 32: call * |
| 124 | |
| 125 | ; 64: t9: |
| 126 | ; 64: callq * |
| 127 | %0 = bitcast i32 (i32)* %x to i16 (i32)* |
| 128 | %1 = tail call signext i16 %0(i32 0) nounwind |
| 129 | ret i16 %1 |
| 130 | } |
Evan Cheng | febc816 | 2010-02-03 03:55:59 +0000 | [diff] [blame] | 131 | |
| 132 | define void @t10() nounwind ssp { |
| 133 | entry: |
| 134 | ; 32: t10: |
| 135 | ; 32: call |
| 136 | |
| 137 | ; 64: t10: |
| 138 | ; 64: callq |
| 139 | %0 = tail call i32 @foo4() noreturn nounwind |
| 140 | unreachable |
| 141 | } |
| 142 | |
| 143 | declare i32 @foo4() |