1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py for function "bar"
2 ; RUN: llc -mtriple=x86_64-unknown-unknown < %s | FileCheck %s
4 ;; In functions with 'no_caller_saved_registers' attribute, all registers should
5 ;; be preserved except for registers used for passing/returning arguments.
6 ;; In the following function registers %rdi, %rsi and %xmm0 are used to store
7 ;; arguments %a0, %a1 and %b0 accordingally. The value is returned in %rax.
8 ;; The above registers should not be preserved, however other registers
9 ;; (that are modified by the function) should be preserved (%rdx and %xmm1).
10 define x86_64_sysvcc i32 @bar(i32 %a0, i32 %a1, float %b0) #0 {
13 ; CHECK-NEXT: pushq %rdx
14 ; CHECK-NEXT: .cfi_def_cfa_offset 16
15 ; CHECK-NEXT: movaps %xmm1, -{{[0-9]+}}(%rsp) # 16-byte Spill
16 ; CHECK-NEXT: .cfi_offset %rdx, -16
17 ; CHECK-NEXT: .cfi_offset %xmm1, -32
20 ; CHECK-NEXT: movl $4, %eax
21 ; CHECK-NEXT: movaps -{{[0-9]+}}(%rsp), %xmm1 # 16-byte Reload
22 ; CHECK-NEXT: popq %rdx
23 ; CHECK-NEXT: .cfi_def_cfa_offset 8
25 call void asm sideeffect "", "~{rax},~{rdx},~{xmm1},~{rdi},~{rsi},~{xmm0}"()
29 ;; Because "bar" has 'no_caller_saved_registers' attribute, function "foo"
30 ;; doesn't need to preserve registers except for the arguments passed
31 ;; to "bar" (%esi, %edi and %xmm0).
32 define x86_64_sysvcc float @foo(i32 %a0, i32 %a1, float %b0) {
34 ; CHECK: movaps %xmm0, %xmm1
35 ; CHECK-NEXT: movl %esi, %ecx
36 ; CHECK-NEXT: movl %edi, %edx
37 ; CHECK-NEXT: callq bar
38 ; CHECK-NEXT: addl %edx, %eax
39 ; CHECK-NEXT: addl %ecx, %eax
40 ; CHECK-NEXT: xorps %xmm0, %xmm0
41 ; CHECK-NEXT: cvtsi2ss %eax, %xmm0
42 ; CHECK-NEXT: addss %xmm0, %xmm1
44 %call = call i32 @bar(i32 %a0, i32 %a1, float %b0) #0
45 %c0 = add i32 %a0, %call
46 %c1 = add i32 %c0, %a1
47 %c2 = sitofp i32 %c1 to float
48 %c3 = fadd float %c2, %b0
52 attributes #0 = { "no_caller_saved_registers" }