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