1# RUN: llc -march=x86-64 -run-pass none -o - %s | FileCheck %s
2# This test ensures that the MIR parser parses callee saved information in the
3# stack objects correctly.
4
5--- |
6
7  define i32 @compute(i32 %a) {
8  body:
9    ret i32 %a
10  }
11
12  define i32 @func(i32 %a) {
13  entry:
14    %b = alloca i32
15    store i32 %a, i32* %b
16    br label %check
17
18  check:
19    %comp = icmp sle i32 %a, 10
20    br i1 %comp, label %loop, label %exit
21
22  loop:
23    %c = load i32, i32* %b
24    %d = call i32 @compute(i32 %c)
25    %e = sub i32 %d, 1
26    store i32 %e, i32* %b
27    br label %check
28
29  exit:
30    ret i32 0
31  }
32
33...
34---
35name:            compute
36tracksRegLiveness: true
37body: |
38  bb.0.body:
39    liveins: $edi
40
41    $eax = COPY killed $edi
42    RETQ killed $eax
43...
44---
45name:            func
46tracksRegLiveness: true
47frameInfo:
48  stackSize:       24
49  maxAlignment:    4
50  adjustsStack:    true
51  hasCalls:        true
52# CHECK: fixedStack:
53# CHECK: callee-saved-register: '$rbx', callee-saved-restored: true
54fixedStack:
55  - { id: 0, type: spill-slot, offset: -16, size: 8, alignment: 16, callee-saved-register: '$rbx' }
56# CHECK: stack:
57# CHECK-NEXT: - { id: 0
58# CHECK: callee-saved-register: '$edi', callee-saved-restored: false
59stack:
60  - { id: 0, name: b, offset: -20, size: 4, alignment: 4 }
61  - { id: 1, offset: -24, size: 4, alignment: 4, callee-saved-register: '$edi',
62      callee-saved-restored: false }
63body: |
64  bb.0.entry:
65    successors: %bb.1.check
66    liveins: $edi, $rbx
67
68    frame-setup PUSH64r killed $rbx, implicit-def $rsp, implicit $rsp
69    $rsp = frame-setup SUB64ri8 $rsp, 16, implicit-def dead $eflags
70    $ebx = COPY $edi
71    MOV32mr $rsp, 1, _, 12, _, $ebx
72
73  bb.1.check:
74    successors: %bb.2.loop, %bb.3.exit
75    liveins: $ebx
76
77    CMP32ri8 $ebx, 10, implicit-def $eflags
78    JCC_1 %bb.3.exit, 15, implicit killed $eflags
79    JMP_1 %bb.2.loop
80
81  bb.2.loop:
82    successors: %bb.1.check
83    liveins: $ebx
84
85    $edi = MOV32rm $rsp, 1, _, 12, _
86    CALL64pcrel32 @compute, csr_64, implicit $rsp, implicit $edi, implicit-def $rsp, implicit-def $eax
87    $eax = DEC32r killed $eax, implicit-def dead $eflags
88    MOV32mr $rsp, 1, _, 12, _, killed $eax
89    JMP_1 %bb.1.check
90
91  bb.3.exit:
92    $eax = MOV32r0 implicit-def dead $eflags
93    $rsp = ADD64ri8 $rsp, 16, implicit-def dead $eflags
94    $rbx = POP64r implicit-def $rsp, implicit $rsp
95    RETQ $eax
96...
97