1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
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]+}}(%r{{[sb]}}p) # 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]+}}(%r{{[sb]}}p), %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) {
35 ; CHECK-NEXT: pushq %rax
36 ; CHECK-NEXT: .cfi_def_cfa_offset 16
37 ; CHECK-NEXT: movaps %xmm0, %xmm1
38 ; CHECK-NEXT: movl %esi, %ecx
39 ; CHECK-NEXT: movl %edi, %edx
40 ; CHECK-NEXT: callq bar@PLT
41 ; CHECK-NEXT: addl %ecx, %edx
42 ; CHECK-NEXT: addl %eax, %edx
43 ; CHECK-NEXT: xorps %xmm0, %xmm0
44 ; CHECK-NEXT: cvtsi2ss %edx, %xmm0
45 ; CHECK-NEXT: addss %xmm1, %xmm0
46 ; CHECK-NEXT: popq %rax
47 ; CHECK-NEXT: .cfi_def_cfa_offset 8
49 %call = call i32 @bar(i32 %a0, i32 %a1, float %b0)
50 %c0 = add i32 %a0, %call
51 %c1 = add i32 %c0, %a1
52 %c2 = sitofp i32 %c1 to float
53 %c3 = fadd float %c2, %b0
57 attributes #0 = { "no_caller_saved_registers" }