[PeepholeOptimizer] Refactor the advanced copy optimization to take advantage of
[oota-llvm.git] / test / CodeGen / ARM / tail-call.ll
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)
6 declare extern_weak fastcc void @callee_weak()
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
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 }