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