1*9880d681SAndroid Build Coastguard Worker; RUN: llc -mtriple armv7 -target-abi apcs -O0 -o - < %s \ 2*9880d681SAndroid Build Coastguard Worker; RUN: | FileCheck %s -check-prefix CHECK-TAIL 3*9880d681SAndroid Build Coastguard Worker; RUN: llc -mtriple armv7 -target-abi apcs -O0 -disable-tail-calls -o - < %s \ 4*9880d681SAndroid Build Coastguard Worker; RUN: | FileCheck %s -check-prefix CHECK-NO-TAIL 5*9880d681SAndroid Build Coastguard Worker 6*9880d681SAndroid Build Coastguard Workerdeclare i32 @callee(i32 %i) 7*9880d681SAndroid Build Coastguard Workerdeclare extern_weak fastcc void @callee_weak() 8*9880d681SAndroid Build Coastguard Worker 9*9880d681SAndroid Build Coastguard Workerdefine i32 @caller(i32 %i) { 10*9880d681SAndroid Build Coastguard Workerentry: 11*9880d681SAndroid Build Coastguard Worker %r = tail call i32 @callee(i32 %i) 12*9880d681SAndroid Build Coastguard Worker ret i32 %r 13*9880d681SAndroid Build Coastguard Worker} 14*9880d681SAndroid Build Coastguard Worker 15*9880d681SAndroid Build Coastguard Worker; CHECK-TAIL-LABEL: caller 16*9880d681SAndroid Build Coastguard Worker; CHECK-TAIL: b callee 17*9880d681SAndroid Build Coastguard Worker 18*9880d681SAndroid Build Coastguard Worker; CHECK-NO-TAIL-LABEL: caller 19*9880d681SAndroid Build Coastguard Worker; CHECK-NO-TAIL: push {lr} 20*9880d681SAndroid Build Coastguard Worker; CHECK-NO-TAIL: bl callee 21*9880d681SAndroid Build Coastguard Worker; CHECK-NO-TAIL: pop {lr} 22*9880d681SAndroid Build Coastguard Worker; CHECK-NO-TAIL: bx lr 23*9880d681SAndroid Build Coastguard Worker 24*9880d681SAndroid Build Coastguard Worker 25*9880d681SAndroid Build Coastguard Worker; Weakly-referenced extern functions cannot be tail-called, as AAELF does 26*9880d681SAndroid Build Coastguard Worker; not define the behaviour of branch instructions to undefined weak symbols. 27*9880d681SAndroid Build Coastguard Workerdefine fastcc void @caller_weak() { 28*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: caller_weak: 29*9880d681SAndroid Build Coastguard Worker; CHECK: bl callee_weak 30*9880d681SAndroid Build Coastguard Worker tail call void @callee_weak() 31*9880d681SAndroid Build Coastguard Worker ret void 32*9880d681SAndroid Build Coastguard Worker} 33