blob: ca19b057773a8a31f1efc4d751fa859ed94e76bd [file] [log] [blame]
Eric Christopher661f2d12014-12-18 02:20:58 +00001; RUN: llc -mtriple armv7 -target-abi apcs -O0 -o - < %s \
Eric Christopher1971c352014-12-18 02:08:45 +00002; RUN: | FileCheck %s -check-prefix CHECK-TAIL
Eric Christopher661f2d12014-12-18 02:20:58 +00003; RUN: llc -mtriple armv7 -target-abi apcs -O0 -disable-tail-calls -o - < %s \
Saleem Abdulrasool0d96f3d2014-03-11 15:09:54 +00004; RUN: | FileCheck %s -check-prefix CHECK-NO-TAIL
5
6declare i32 @callee(i32 %i)
Oliver Stannard12993dd2014-08-18 12:42:15 +00007declare extern_weak fastcc void @callee_weak()
Saleem Abdulrasool0d96f3d2014-03-11 15:09:54 +00008
9define i32 @caller(i32 %i) {
10entry:
11 %r = tail call i32 @callee(i32 %i)
12 ret i32 %r
13}
14
Saleem Abdulrasool14256222014-03-25 03:39:39 +000015; CHECK-TAIL-LABEL: caller
Saleem Abdulrasool0d96f3d2014-03-11 15:09:54 +000016; CHECK-TAIL: b callee
17
Saleem Abdulrasool14256222014-03-25 03:39:39 +000018; CHECK-NO-TAIL-LABEL: caller
Saleem Abdulrasool0d96f3d2014-03-11 15:09:54 +000019; CHECK-NO-TAIL: push {lr}
20; CHECK-NO-TAIL: bl callee
21; CHECK-NO-TAIL: pop {lr}
22; CHECK-NO-TAIL: bx lr
23
Oliver Stannard12993dd2014-08-18 12:42:15 +000024
25; Weakly-referenced extern functions cannot be tail-called, as AAELF does
26; not define the behaviour of branch instructions to undefined weak symbols.
27define fastcc void @caller_weak() {
28; CHECK-LABEL: caller_weak:
29; CHECK: bl callee_weak
30 tail call void @callee_weak()
31 ret void
32}