| Stephen Hines | 36b5688 | 2014-04-23 16:57:46 -0700 | [diff] [blame] | 1 | ; RUN: llc -mtriple armv7 -O0 -o - < %s | FileCheck %s -check-prefix CHECK-TAIL |
| 2 | ; RUN: llc -mtriple armv7 -O0 -disable-tail-calls -o - < %s \ |
| 3 | ; RUN: | FileCheck %s -check-prefix CHECK-NO-TAIL |
| 4 | |
| 5 | declare i32 @callee(i32 %i) |
| Stephen Hines | 37ed9c1 | 2014-12-01 14:51:49 -0800 | [diff] [blame^] | 6 | declare extern_weak fastcc void @callee_weak() |
| Stephen Hines | 36b5688 | 2014-04-23 16:57:46 -0700 | [diff] [blame] | 7 | |
| 8 | define i32 @caller(i32 %i) { |
| 9 | entry: |
| 10 | %r = tail call i32 @callee(i32 %i) |
| 11 | ret i32 %r |
| 12 | } |
| 13 | |
| 14 | ; CHECK-TAIL-LABEL: caller |
| 15 | ; CHECK-TAIL: b callee |
| 16 | |
| 17 | ; CHECK-NO-TAIL-LABEL: caller |
| 18 | ; CHECK-NO-TAIL: push {lr} |
| 19 | ; CHECK-NO-TAIL: bl callee |
| 20 | ; CHECK-NO-TAIL: pop {lr} |
| 21 | ; CHECK-NO-TAIL: bx lr |
| 22 | |
| Stephen Hines | 37ed9c1 | 2014-12-01 14:51:49 -0800 | [diff] [blame^] | 23 | |
| 24 | ; Weakly-referenced extern functions cannot be tail-called, as AAELF does |
| 25 | ; not define the behaviour of branch instructions to undefined weak symbols. |
| 26 | define fastcc void @caller_weak() { |
| 27 | ; CHECK-LABEL: caller_weak: |
| 28 | ; CHECK: bl callee_weak |
| 29 | tail call void @callee_weak() |
| 30 | ret void |
| 31 | } |