• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc -verify-machineinstrs -mtriple=armv7k-apple-ios8.0 -mcpu=cortex-a7 -o - %s | FileCheck --check-prefix=CHECK --check-prefix=OPT --check-prefix=TAILCALL %s
2; RUN: llc -O0 -verify-machineinstrs -mtriple=armv7k-apple-ios8.0 -mcpu=cortex-a7 -o - %s | FileCheck %s
3
4; RUN: llc -verify-machineinstrs -mtriple=armv7-apple-ios -o - %s | FileCheck --check-prefix=CHECK --check-prefix=OPT %s
5; RUN: llc -O0 -verify-machineinstrs -mtriple=armv7-apple-ios -o - %s | FileCheck %s
6
7; Parameter with swiftself should be allocated to r10.
8; CHECK-LABEL: swiftself_param:
9; CHECK: mov r0, r10
10define i8 *@swiftself_param(i8* swiftself %addr0) {
11    ret i8 *%addr0
12}
13
14; Check that r10 is used to pass a swiftself argument.
15; CHECK-LABEL: call_swiftself:
16; CHECK: mov r10, r0
17; CHECK: bl {{_?}}swiftself_param
18define i8 *@call_swiftself(i8* %arg) {
19  %res = call i8 *@swiftself_param(i8* swiftself %arg)
20  ret i8 *%res
21}
22
23; r10 should be saved by the callee even if used for swiftself
24; CHECK-LABEL: swiftself_clobber:
25; CHECK: push {r10}
26; ...
27; CHECK: pop {r10}
28define i8 *@swiftself_clobber(i8* swiftself %addr0) {
29  call void asm sideeffect "", "~{r10}"()
30  ret i8 *%addr0
31}
32
33; Demonstrate that we do not need any movs when calling multiple functions
34; with swiftself argument.
35; CHECK-LABEL: swiftself_passthrough:
36; OPT-NOT: mov{{.*}}r10
37; OPT: bl {{_?}}swiftself_param
38; OPT-NOT: mov{{.*}}r10
39; OPT-NEXT: bl {{_?}}swiftself_param
40define void @swiftself_passthrough(i8* swiftself %addr0) {
41  call i8 *@swiftself_param(i8* swiftself %addr0)
42  call i8 *@swiftself_param(i8* swiftself %addr0)
43  ret void
44}
45
46; We can use a tail call if the callee swiftself is the same as the caller one.
47; CHECK-LABEL: swiftself_tail:
48; TAILCALL: b {{_?}}swiftself_param
49; TAILCALL-NOT: pop
50define i8* @swiftself_tail(i8* swiftself %addr0) {
51  call void asm sideeffect "", "~{r10}"()
52  %res = tail call i8* @swiftself_param(i8* swiftself %addr0)
53  ret i8* %res
54}
55
56; We can not use a tail call if the callee swiftself is not the same as the
57; caller one.
58; CHECK-LABEL: swiftself_notail:
59; CHECK: mov r10, r0
60; CHECK: bl {{_?}}swiftself_param
61; CHECK: pop
62define i8* @swiftself_notail(i8* swiftself %addr0, i8* %addr1) nounwind {
63  %res = tail call i8* @swiftself_param(i8* swiftself %addr1)
64  ret i8* %res
65}
66