1# RUN: llc -march=x86-64 -start-after branch-folder -stop-after branch-folder -o /dev/null %s | FileCheck %s
2# This test ensures that the MIR parser parses basic block successors correctly.
3
4--- |
5
6  define i32 @foo(i32 %a) {
7  entry:
8    %0 = icmp sle i32 %a, 10
9    br i1 %0, label %less, label %exit
10
11  less:
12    ret i32 0
13
14  exit:
15    ret i32 %a
16  }
17
18  define i32 @bar(i32 %a) {
19  entry:
20    %b = icmp sle i32 %a, 10
21    br i1 %b, label %0, label %1
22
23  ; <label>:0
24    ret i32 0
25
26  ; <label>:1
27    ret i32 %a
28  }
29
30...
31---
32name:            foo
33body: |
34  ; CHECK-LABEL: bb.0.entry:
35  ; CHECK:         successors: %bb.1.less(0x40000000 / 0x80000000 = 50.00%), %bb.2.exit(0x40000000 / 0x80000000 = 50.00%)
36  ; CHECK-LABEL: bb.1.less:
37  bb.0.entry:
38    successors: %bb.1.less, %bb.2.exit
39    liveins: %edi
40
41    CMP32ri8 %edi, 10, implicit-def %eflags
42    JG_1 %bb.2.exit, implicit killed %eflags
43
44  bb.1.less:
45    %eax = MOV32r0 implicit-def dead %eflags
46    RETQ killed %eax
47
48  bb.2.exit:
49    liveins: %edi
50
51    %eax = COPY killed %edi
52    RETQ killed %eax
53...
54---
55name:            bar
56body: |
57  ; CHECK-LABEL: name: bar
58  ; Verify that we can have multiple lists of successors that will be merged
59  ; into one.
60  ; CHECK-LABEL: bb.0.entry:
61  ; CHECK:         successors: %bb.1(0x80000000 / 0x80000000 = 100.00%), %bb.2(0x00000000 / 0x80000000 = 0.00%)
62  bb.0.entry:
63    liveins: %edi
64    successors: %bb.1
65    successors: %bb.2
66
67    CMP32ri8 %edi, 10, implicit-def %eflags
68    JG_1 %bb.2, implicit killed %eflags
69
70  ; Verify that we can have an empty list of successors.
71  ; CHECK-LABEL: bb.1:
72  ; CHECK-NEXT:  %eax = MOV32r0 implicit-def dead %eflags
73  bb.1:
74    successors:
75    %eax = MOV32r0 implicit-def dead %eflags
76    RETQ killed %eax
77
78  bb.2:
79    liveins: %edi
80
81    %eax = COPY killed %edi
82    RETQ killed %eax
83...
84