1 ; RUN: llc -mtriple=x86_64-apple-darwin -stop-after finalize-isel <%s | FileCheck %s
3 ; Check that the callee excludes the return register (%rax) from the list of
4 ; callee-saved-registers.
5 define preserve_allcc i64 @callee1(i64 %a0, i64 %b0, i64 %c0, i64 %d0, i64 %e0) nounwind {
12 ; CHECK: name: callee1
13 ; CHECK: calleeSavedRegisters: [ '$rbx', '$r12', '$r13', '$r14', '$r15', '$rbp',
14 ; CHECK: '$rcx', '$rdx', '$rsi', '$rdi', '$r8', '$r9', '$r10',
15 ; CHECK: '$xmm0', '$xmm1', '$xmm2', '$xmm3', '$xmm4', '$xmm5',
16 ; CHECK: '$xmm6', '$xmm7', '$xmm8', '$xmm9', '$xmm10', '$xmm11',
17 ; CHECK: '$xmm12', '$xmm13', '$xmm14', '$xmm15' ]
20 ; Check that RegMask contains parameter registers (%rdi, %rsi, %rdx, %rcx,
21 ; %r8), but doesn't contain the return register (%rax).
22 define i64 @caller1(i64 %a0) nounwind {
23 %b1 = call preserve_allcc i64 @callee1(i64 %a0, i64 %a0, i64 %a0, i64 %a0, i64 %a0)
24 %b2 = add i64 %b1, %a0
27 ; CHECK: name: caller1
28 ; CHECK: CALL64pcrel32 @callee1, CustomRegMask($bh,$bl,$bp,$bph,$bpl,$bx,$ch,$cl,$cx,$dh,$di,$dih,$dil,$dl,$dx,$ebp,$ebx,$ecx,$edi,$edx,$esi,$hbp,$hbx,$hcx,$hdi,$hdx,$hsi,$rbp,$rbx,$rcx,$rdi,$rdx,$rsi,$si,$sih,$sil,$r8,$r9,$r10,$r12,$r13,$r14,$r15,$xmm0,$xmm1,$xmm2,$xmm3,$xmm4,$xmm5,$xmm6,$xmm7,$xmm8,$xmm9,$xmm10,$xmm11,$xmm12,$xmm13,$xmm14,$xmm15,$r8b,$r9b,$r10b,$r12b,$r13b,$r14b,$r15b,$r8bh,$r9bh,$r10bh,$r12bh,$r13bh,$r14bh,$r15bh,$r8d,$r9d,$r10d,$r12d,$r13d,$r14d,$r15d,$r8w,$r9w,$r10w,$r12w,$r13w,$r14w,$r15w,$r8wh,$r9wh,$r10wh,$r12wh,$r13wh,$r14wh,$r15wh), implicit $rsp, implicit $ssp, implicit $rdi, implicit $rsi, implicit $rdx, implicit $rcx, implicit $r8, implicit-def $rsp, implicit-def $ssp, implicit-def $rax
32 ; Check that the callee excludes the return registers (%rax, %rdx) from the list
33 ; of callee-saved-registers.
34 define preserve_allcc {i64, i64} @callee2(i64 %a0, i64 %b0, i64 %c0, i64 %d0, i64 %e0) nounwind {
35 %a1 = mul i64 %a0, %b0
36 %a2 = mul i64 %a1, %c0
37 %a3 = mul i64 %a2, %d0
38 %a4 = mul i64 %a3, %e0
39 %b4 = insertvalue {i64, i64} undef, i64 %a3, 0
40 %b5 = insertvalue {i64, i64} %b4, i64 %a4, 1
43 ; CHECK: name: callee2
44 ; CHECK: calleeSavedRegisters: [ '$rbx', '$r12', '$r13', '$r14', '$r15', '$rbp',
45 ; CHECK: '$rcx', '$rsi', '$rdi', '$r8', '$r9', '$r10', '$xmm0',
46 ; CHECK: '$xmm1', '$xmm2', '$xmm3', '$xmm4', '$xmm5', '$xmm6',
47 ; CHECK: '$xmm7', '$xmm8', '$xmm9', '$xmm10', '$xmm11',
48 ; CHECK: '$xmm12', '$xmm13', '$xmm14', '$xmm15' ]
49 ; CHECK: RET 0, $rax, $rdx
52 ; Check that RegMask contains parameter registers (%rdi, %rsi, %rdx, %rcx,
53 ; %r8), but doesn't contain the return registers (%rax, %rdx).
54 define {i64, i64} @caller2(i64 %a0) nounwind {
55 %b1 = call preserve_allcc {i64, i64} @callee2(i64 %a0, i64 %a0, i64 %a0, i64 %a0, i64 %a0)
58 ; CHECK: name: caller2
59 ; CHECL: CALL64pcrel32 @callee2, CustomRegMask($bh,$bl,$bp,$bph,$bpl,$bx,$ch,$cl,$cx,$di,$dih,$dil,$ebp,$ebx,$ecx,$edi,$esi,$hbp,$hbx,$hcx,$hdi,$hsi,$rbp,$rbx,$rcx,$rdi,$rsi,$si,$sih,$sil,$r8,$r9,$r10,$r12,$r13,$r14,$r15,$xmm0,$xmm1,$xmm2,$xmm3,$xmm4,$xmm5,$xmm6,$xmm7,$xmm8,$xmm9,$xmm10,$xmm11,$xmm12,$xmm13,$xmm14,$xmm15,$r8b,$r9b,$r10b,$r12b,$r13b,$r14b,$r15b,$r8bh,$r9bh,$r10bh,$r12bh,$r13bh,$r14bh,$r15bh,$r8d,$r9d,$r10d,$r12d,$r13d,$r14d,$r15d,$r8w,$r9w,$r10w,$r12w,$r13w,$r14w,$r15w,$r8wh,$r9wh,$r10wh,$r12wh,$r13wh,$r14wh,$r15wh), implicit $rsp, implicit $ssp, implicit $rdi, implicit $rsi, implicit $rdx, implicit $rcx, implicit $r8, implicit-def $rsp, implicit-def $ssp, implicit-def $rax, implicit-def $rdx
60 ; CHECK: RET 0, $rax, $rdx
63 %struct.Large = type { i64, double, double }
65 ; Declare the callee with a sret parameter.
66 declare preserve_allcc void @callee3(ptr noalias nocapture writeonly sret(%struct.Large) align 4 %a0, i64 %b0) nounwind;
68 ; Check that RegMask contains %rax and subregisters.
69 define void @caller3(i64 %a0) nounwind {
70 %a1 = alloca %struct.Large, align 8
71 call preserve_allcc void @callee3(ptr nonnull sret(%struct.Large) align 8 %a1, i64 %a0)
74 ; CHECK: name: caller3
75 ; CHECK: CALL64pcrel32 @callee3, CustomRegMask($ah,$al,$ax,$bh,$bl,$bp,$bph,$bpl,$bx,$ch,$cl,$cx,$dh,$di,$dih,$dil,$dl,$dx,$eax,$ebp,$ebx,$ecx,$edi,$edx,$esi,$hax,$hbp,$hbx,$hcx,$hdi,$hdx,$hsi,$rax,$rbp,$rbx,$rcx,$rdi,$rdx,$rsi,$si,$sih,$sil,$r8,$r9,$r10,$r12,$r13,$r14,$r15,$xmm0,$xmm1,$xmm2,$xmm3,$xmm4,$xmm5,$xmm6,$xmm7,$xmm8,$xmm9,$xmm10,$xmm11,$xmm12,$xmm13,$xmm14,$xmm15,$r8b,$r9b,$r10b,$r12b,$r13b,$r14b,$r15b,$r8bh,$r9bh,$r10bh,$r12bh,$r13bh,$r14bh,$r15bh,$r8d,$r9d,$r10d,$r12d,$r13d,$r14d,$r15d,$r8w,$r9w,$r10w,$r12w,$r13w,$r14w,$r15w,$r8wh,$r9wh,$r10wh,$r12wh,$r13wh,$r14wh,$r15wh), implicit $rsp, implicit $ssp, implicit $rdi, implicit $rsi, implicit-def $rsp, implicit-def $ssp
79 ; Check that the callee excludes the return registers (%rax, %xmm0) from the list
80 ; of callee-saved-registers.
81 define preserve_allcc {i64, double} @callee4(i64 %a0, i64 %b0, i64 %c0, i64 %d0, i64 %e0) nounwind {
82 %a1 = mul i64 %a0, %b0
83 %a2 = mul i64 %a1, %c0
84 %a3 = mul i64 %a2, %d0
85 %a4 = mul i64 %a3, %e0
86 %b4 = insertvalue {i64, double} undef, i64 %a3, 0
87 %b5 = insertvalue {i64, double} %b4, double 1.2, 1
90 ; CHECK: name: callee4
91 ; CHECK: calleeSavedRegisters: [ '$rbx', '$r12', '$r13', '$r14', '$r15', '$rbp',
92 ; CHECK: '$rcx', '$rdx', '$rsi', '$rdi', '$r8', '$r9', '$r10',
93 ; CHECK: '$xmm1', '$xmm2', '$xmm3', '$xmm4', '$xmm5', '$xmm6',
94 ; CHECK: '$xmm7', '$xmm8', '$xmm9', '$xmm10', '$xmm11',
95 ; CHECK: '$xmm12', '$xmm13', '$xmm14', '$xmm15' ]
96 ; CHECK: RET 0, $rax, $xmm0
98 ; Check that RegMask contains parameter registers (%rdi, %rsi, %rdx, %rcx,
99 ; %r8), but doesn't contain the return registers (%rax, %xmm0).
100 define {i64, double} @caller4(i64 %a0) nounwind {
101 %b1 = call preserve_allcc {i64, double} @callee4(i64 %a0, i64 %a0, i64 %a0, i64 %a0, i64 %a0)
102 ret {i64, double} %b1
104 ; CHECK: name: caller4
105 ; CHECK: CALL64pcrel32 @callee4, CustomRegMask($bh,$bl,$bp,$bph,$bpl,$bx,$ch,$cl,$cx,$dh,$di,$dih,$dil,$dl,$dx,$ebp,$ebx,$ecx,$edi,$edx,$esi,$hbp,$hbx,$hcx,$hdi,$hdx,$hsi,$rbp,$rbx,$rcx,$rdi,$rdx,$rsi,$si,$sih,$sil,$r8,$r9,$r10,$r12,$r13,$r14,$r15,$xmm1,$xmm2,$xmm3,$xmm4,$xmm5,$xmm6,$xmm7,$xmm8,$xmm9,$xmm10,$xmm11,$xmm12,$xmm13,$xmm14,$xmm15,$r8b,$r9b,$r10b,$r12b,$r13b,$r14b,$r15b,$r8bh,$r9bh,$r10bh,$r12bh,$r13bh,$r14bh,$r15bh,$r8d,$r9d,$r10d,$r12d,$r13d,$r14d,$r15d,$r8w,$r9w,$r10w,$r12w,$r13w,$r14w,$r15w,$r8wh,$r9wh,$r10wh,$r12wh,$r13wh,$r14wh,$r15wh), implicit $rsp, implicit $ssp, implicit $rdi, implicit $rsi, implicit $rdx, implicit $rcx, implicit $r8, implicit-def $rsp, implicit-def $ssp, implicit-def $rax, implicit-def $xmm0
107 ; CHECK: RET 0, $rax, $xmm0