[InstCombine] Signed saturation patterns
[llvm-core.git] / test / CodeGen / ARM / swiftself.ll
blob1e06b34c7052905695bdcae233c1fb9f7d59e1e9
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
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
7 ; Parameter with swiftself should be allocated to r10.
8 ; CHECK-LABEL: swiftself_param:
9 ; CHECK: mov r0, r10
10 define i8 *@swiftself_param(i8* swiftself %addr0) "no-frame-pointer-elim"="true" {
11     ret i8 *%addr0
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
18 define i8 *@call_swiftself(i8* %arg) "no-frame-pointer-elim"="true" {
19   %res = call i8 *@swiftself_param(i8* swiftself %arg)
20   ret i8 *%res
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}
28 define i8 *@swiftself_clobber(i8* swiftself %addr0) "no-frame-pointer-elim"="true" {
29   call void asm sideeffect "", "~{r10}"()
30   ret i8 *%addr0
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
40 define void @swiftself_passthrough(i8* swiftself %addr0) "no-frame-pointer-elim"="true" {
41   call i8 *@swiftself_param(i8* swiftself %addr0)
42   call i8 *@swiftself_param(i8* swiftself %addr0)
43   ret void
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
50 define i8* @swiftself_tail(i8* swiftself %addr0) "no-frame-pointer-elim"="true" {
51   call void asm sideeffect "", "~{r10}"()
52   %res = tail call i8* @swiftself_param(i8* swiftself %addr0)
53   ret i8* %res
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
62 define i8* @swiftself_notail(i8* swiftself %addr0, i8* %addr1) nounwind "no-frame-pointer-elim"="true" {
63   %res = tail call i8* @swiftself_param(i8* swiftself %addr1)
64   ret i8* %res
67 ; We cannot pretend that 'r0' is alive across the thisreturn_attribute call as
68 ; we normally would. We marked the first parameter with swiftself which means it
69 ; will no longer be passed in r0.
70 declare swiftcc i8* @thisreturn_attribute(i8* returned swiftself)
71 ; OPT-LABEL: swiftself_nothisreturn:
72 ; OPT-DAG: mov [[CSREG:r[1-9].*]], r0
73 ; OPT-DAG: ldr r10, [r10]
74 ; OPT: bl  {{_?}}thisreturn_attribute
75 ; OPT: str r0, {{\[}}[[CSREG]]
76 define hidden swiftcc void @swiftself_nothisreturn(i8** noalias nocapture sret, i8** noalias nocapture readonly swiftself) {
77 entry:
78   %2 = load i8*, i8** %1, align 8
79   %3 = tail call swiftcc i8* @thisreturn_attribute(i8* swiftself %2)
80   store i8* %3, i8** %0, align 8
81   ret void