blob: c3e79652c035119b7afeb95d415520c9302e8b3b [file] [log] [blame]
Saleem Abdulrasool0d96f3d2014-03-11 15:09:54 +00001; 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
5declare i32 @callee(i32 %i)
Oliver Stannard12993dd2014-08-18 12:42:15 +00006declare extern_weak fastcc void @callee_weak()
Saleem Abdulrasool0d96f3d2014-03-11 15:09:54 +00007
8define i32 @caller(i32 %i) {
9entry:
10 %r = tail call i32 @callee(i32 %i)
11 ret i32 %r
12}
13
Saleem Abdulrasool14256222014-03-25 03:39:39 +000014; CHECK-TAIL-LABEL: caller
Saleem Abdulrasool0d96f3d2014-03-11 15:09:54 +000015; CHECK-TAIL: b callee
16
Saleem Abdulrasool14256222014-03-25 03:39:39 +000017; CHECK-NO-TAIL-LABEL: caller
Saleem Abdulrasool0d96f3d2014-03-11 15:09:54 +000018; CHECK-NO-TAIL: push {lr}
19; CHECK-NO-TAIL: bl callee
20; CHECK-NO-TAIL: pop {lr}
21; CHECK-NO-TAIL: bx lr
22
Oliver Stannard12993dd2014-08-18 12:42:15 +000023
24; Weakly-referenced extern functions cannot be tail-called, as AAELF does
25; not define the behaviour of branch instructions to undefined weak symbols.
26define fastcc void @caller_weak() {
27; CHECK-LABEL: caller_weak:
28; CHECK: bl callee_weak
29 tail call void @callee_weak()
30 ret void
31}