1 ; RUN: llc < %s -mtriple=x86_64-apple-darwin | FileCheck %s
3 %struct.Large = type { [64 x i32] }
5 ; Check that %rax is also preserved for a function with sret parameter,
6 define preserve_mostcc void @sret_foo(ptr noalias nocapture writeonly sret(%struct.Large) align 4, i32 noundef) nounwind {
10 ;CHECK-NEXT: pushq %r8
11 ;CHECK-NEXT: pushq %rdi
12 ;CHECK-NEXT: pushq %rsi
13 ;CHECK-NEXT: pushq %rdx
14 ;CHECK-NEXT: pushq %rcx
15 ;CHECK-NEXT: pushq %rax
16 ;CHECK-NEXT: pushq %rbp
17 ;CHECK-NEXT: pushq %r15
18 ;CHECK-NEXT: pushq %r14
19 ;CHECK-NEXT: pushq %r13
20 ;CHECK-NEXT: pushq %r12
21 ;CHECK-NEXT: pushq %rbx
23 ;CHECK-NEXT: popq %r12
24 ;CHECK-NEXT: popq %r13
25 ;CHECK-NEXT: popq %r14
26 ;CHECK-NEXT: popq %r15
27 ;CHECK-NEXT: popq %rbp
28 ;CHECK-NEXT: popq %rax
29 ;CHECK-NEXT: popq %rcx
30 ;CHECK-NEXT: popq %rdx
31 ;CHECK-NEXT: popq %rsi
32 ;CHECK-NEXT: popq %rdi
35 ;CHECK-NEXT: popq %r10
36 call void asm sideeffect "", "~{rax},~{rbx},~{rcx},~{rdx},~{rsi},~{rdi},~{r8},~{r9},~{r10},~{r11},~{r12},~{r13},~{r14},~{r15},~{rbp},~{xmm0},~{xmm1},~{xmm2},~{xmm3},~{xmm4},~{xmm5},~{xmm6},~{xmm7},~{xmm8},~{xmm9},~{xmm10},~{xmm11},~{xmm12},~{xmm13},~{xmm14},~{xmm15}"()
40 ; Check that neither %rax no %rdi are caller-saved.
41 define void @foo(ptr noalias nocapture writeonly sret(%struct.Large) align 4 %0, i32 noundef %1) nounwind {
43 ;CHECK-NOT: movq %rax, [[REG1:%[a-z0-9]+]]
44 ;CHECK-NOT: movq %rdi, [[REG2:%[a-z0-9]+]]
45 ;CHECK: movq %r11, [[REG3:%[a-z0-9]+]]
61 ;CHECK-NOT: movq {{.*}}, %rax
62 ;CHECK-NOT: movq {{.*}}, %rdi
63 ;CHECK: movq [[REG3]], %r11
64 ;CHECK: movaps {{.*}} %xmm2
65 ;CHECK: movaps {{.*}} %xmm3
66 ;CHECK: movaps {{.*}} %xmm4
67 ;CHECK: movaps {{.*}} %xmm5
68 ;CHECK: movaps {{.*}} %xmm6
69 ;CHECK: movaps {{.*}} %xmm7
70 ;CHECK: movaps {{.*}} %xmm8
71 ;CHECK: movaps {{.*}} %xmm9
72 ;CHECK: movaps {{.*}} %xmm10
73 ;CHECK: movaps {{.*}} %xmm11
74 ;CHECK: movaps {{.*}} %xmm12
75 ;CHECK: movaps {{.*}} %xmm13
76 ;CHECK: movaps {{.*}} %xmm14
77 ;CHECK: movaps {{.*}} %xmm15
78 %a0 = call i64 asm sideeffect "", "={rax}"() nounwind
79 %a1 = call i64 asm sideeffect "", "={rcx}"() nounwind
80 %a2 = call i64 asm sideeffect "", "={rdx}"() nounwind
81 %a3 = call i64 asm sideeffect "", "={r8}"() nounwind
82 %a4 = call i64 asm sideeffect "", "={r9}"() nounwind
83 %a5 = call i64 asm sideeffect "", "={r10}"() nounwind
84 %a6 = call i64 asm sideeffect "", "={r11}"() nounwind
85 %a10 = call <2 x double> asm sideeffect "", "={xmm2}"() nounwind
86 %a11 = call <2 x double> asm sideeffect "", "={xmm3}"() nounwind
87 %a12 = call <2 x double> asm sideeffect "", "={xmm4}"() nounwind
88 %a13 = call <2 x double> asm sideeffect "", "={xmm5}"() nounwind
89 %a14 = call <2 x double> asm sideeffect "", "={xmm6}"() nounwind
90 %a15 = call <2 x double> asm sideeffect "", "={xmm7}"() nounwind
91 %a16 = call <2 x double> asm sideeffect "", "={xmm8}"() nounwind
92 %a17 = call <2 x double> asm sideeffect "", "={xmm9}"() nounwind
93 %a18 = call <2 x double> asm sideeffect "", "={xmm10}"() nounwind
94 %a19 = call <2 x double> asm sideeffect "", "={xmm11}"() nounwind
95 %a20 = call <2 x double> asm sideeffect "", "={xmm12}"() nounwind
96 %a21 = call <2 x double> asm sideeffect "", "={xmm13}"() nounwind
97 %a22 = call <2 x double> asm sideeffect "", "={xmm14}"() nounwind
98 %a23 = call <2 x double> asm sideeffect "", "={xmm15}"() nounwind
99 call preserve_mostcc void @sret_foo(ptr sret(%struct.Large) align 4 %0, i32 noundef %1)
100 call void asm sideeffect "", "{rax},{rcx},{rdx},{r8},{r9},{r10},{r11},{xmm2},{xmm3},{xmm4},{xmm5},{xmm6},{xmm7},{xmm8},{xmm9},{xmm10},{xmm11},{xmm12},{xmm13},{xmm14},{xmm15}"(i64 %a0, i64 %a1, i64 %a2, i64 %a3, i64 %a4, i64 %a5, i64 %a6, <2 x double> %a10, <2 x double> %a11, <2 x double> %a12, <2 x double> %a13, <2 x double> %a14, <2 x double> %a15, <2 x double> %a16, <2 x double> %a17, <2 x double> %a18, <2 x double> %a19, <2 x double> %a20, <2 x double> %a21, <2 x double> %a22, <2 x double> %a23)