4ec5b50c3643473f4b251b3c46a6f136f02bc2e4
[oota-llvm.git] / test / CodeGen / MIR / X86 / callee-saved-info.mir
1 # RUN: llc -march=x86-64 -start-after prologepilog -stop-after prologepilog -o /dev/null %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 ---
35 name:            compute
36 tracksRegLiveness: true
37 body:
38   - id:          0
39     name:        body
40     liveins:     [ '%edi' ]
41     instructions:
42       - '%eax = COPY killed %edi'
43       - 'RETQ killed %eax'
44 ...
45 ---
46 name:            func
47 tracksRegLiveness: true
48 frameInfo:
49   stackSize:       24
50   maxAlignment:    4
51   adjustsStack:    true
52   hasCalls:        true
53 # CHECK: fixedStack:
54 # CHECK-NEXT: , callee-saved-register: '%rbx' }
55 fixedStack:
56   - { id: 0, type: spill-slot, offset: -16, size: 8, alignment: 16, callee-saved-register: '%rbx' }
57 # CHECK: stack:
58 # CHECK-NEXT: - { id: 0
59 # CHECK-NEXT: , callee-saved-register: '%edi' }
60 stack:
61   - { id: 0, name: b, offset: -20, size: 4, alignment: 4 }
62   - { id: 1, offset: -24, size: 4, alignment: 4, callee-saved-register: '%edi' }
63 body:
64   - id:          0
65     name:        entry
66     successors:  [ '%bb.1.check' ]
67     liveins:     [ '%edi', '%rbx' ]
68     instructions:
69       - 'frame-setup PUSH64r killed %rbx, implicit-def %rsp, implicit %rsp'
70       - '%rsp = frame-setup SUB64ri8 %rsp, 16, implicit-def dead %eflags'
71       - '%ebx = COPY %edi'
72       - 'MOV32mr %rsp, 1, _, 12, _, %ebx'
73   - id:          1
74     name:        check
75     successors:  [ '%bb.2.loop', '%bb.3.exit' ]
76     liveins:     [ '%ebx' ]
77     instructions:
78       - 'CMP32ri8 %ebx, 10, implicit-def %eflags'
79       - 'JG_1 %bb.3.exit, implicit killed %eflags'
80       - 'JMP_1 %bb.2.loop'
81   - id:          2
82     name:        loop
83     successors:  [ '%bb.1.check' ]
84     liveins:     [ '%ebx' ]
85     instructions:
86       - '%edi = MOV32rm %rsp, 1, _, 12, _'
87       - 'CALL64pcrel32 @compute, csr_64, implicit %rsp, implicit %edi, implicit-def %rsp, implicit-def %eax'
88       - '%eax = DEC32r killed %eax, implicit-def dead %eflags'
89       - 'MOV32mr %rsp, 1, _, 12, _, killed %eax'
90       - 'JMP_1 %bb.1.check'
91   - id:          3
92     name:        exit
93     instructions:
94       - '%eax = MOV32r0 implicit-def dead %eflags'
95       - '%rsp = ADD64ri8 %rsp, 16, implicit-def dead %eflags'
96       - '%rbx = POP64r implicit-def %rsp, implicit %rsp'
97       - 'RETQ %eax'
98 ...