1; RUN: llc < %s -mtriple=arm-apple-ios | FileCheck %s
2; RUN: llc < %s -mtriple=thumbv6-apple-ios | FileCheck %s
3; RUN: llc < %s -mtriple=arm-apple-ios -regalloc=basic | FileCheck %s
4; RUN: llc < %s -mtriple=thumbv6-apple-ios -regalloc=basic | FileCheck %s
5; rdar://8015977
6; rdar://8020118
7
8define i8* @rt0(i32 %x) nounwind readnone {
9entry:
10; CHECK-LABEL: rt0:
11; CHECK: mov r0, lr
12  %0 = tail call i8* @llvm.returnaddress(i32 0)
13  ret i8* %0
14}
15
16define i8* @rt2() nounwind readnone {
17entry:
18; CHECK-LABEL: rt2:
19; CHECK: ldr r[[R0:[0-9]+]], [r7]
20; CHECK: ldr r0, [r[[R0]]]
21; CHECK: ldr r0, [r[[R0]], #4]
22  %0 = tail call i8* @llvm.returnaddress(i32 2)
23  ret i8* %0
24}
25
26declare i8* @llvm.returnaddress(i32) nounwind readnone
27