llvm.org GIT mirror llvm / ccba68a
MIR Parser: Report an error when parsing machine function with an empty body. This commit adds a new error which is reported when the MIR Parser encounters a machine function without any machine basic blocks. The machine verifier expects that the machine functions have at least one MBB, and this error will prevent machine functions without MBBs from reaching the machine verifier and crashing with an assertion. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241862 91177308-0d34-0410-b5e6-96231b3b80d8 Alex Lorenz 5 years ago
8 changed file(s) with 42 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
274274 Twine(YamlMBB.ID));
275275 }
276276
277 if (YamlMF.BasicBlocks.empty())
278 return error(Twine("machine function '") + Twine(MF.getName()) +
279 "' requires at least one machine basic block in its body");
277280 // Initialize the machine basic blocks after creating them all so that the
278281 // machine instructions parser can resolve the MBB references.
279282 unsigned I = 0;
3131 ...
3232 ---
3333 name: foo
34 body:
35 - id: 0
3436 ...
33 ---
44 # CHECK: name: foo
55 name: foo
6 body:
7 - id: 0
68 ...
0 # RUN: not llc -start-after branch-folder -stop-after branch-folder -o /dev/null %s 2>&1 | FileCheck %s
1 # This test ensures that the MIR parser reports an error when it encounters a
2 # machine function with an empty body.
3
4 --- |
5
6 define i32 @foo() {
7 ret i32 0
8 }
9
10 ...
11 ---
12 # CHECK: machine function 'foo' requires at least one machine basic block in its body
13 name: foo
14 ...
1111 ...
1212 ---
1313 name: foo
14 body:
15 - id: 0
1416 ...
1517 ---
1618 # CHECK: function 'faa' isn't defined in the provided LLVM IR
1719 name: faa
20 body:
21 - id: 0
1822 ...
1515 ---
1616 # CHECK: [[@LINE+1]]:1: missing required key 'name'
1717 nme: foo
18 body:
19 - id: 0
1820 ...
1921 ---
2022 name: bar
23 body:
24 - id: 0
2125 ...
2626 # CHECK-NEXT: hasInlineAsm: false
2727 # CHECK: ...
2828 name: foo
29 body:
30 - id: 0
2931 ...
3032 ---
3133 # CHECK: name: bar
3436 # CHECK-NEXT: hasInlineAsm: false
3537 # CHECK: ...
3638 name: bar
39 body:
40 - id: 0
3741 ...
3842 ---
3943 # CHECK: name: func
4347 # CHECK: ...
4448 name: func
4549 alignment: 8
50 body:
51 - id: 0
4652 ...
4753 ---
4854 # CHECK: name: func2
5460 alignment: 16
5561 exposesReturnsTwice: true
5662 hasInlineAsm: true
63 body:
64 - id: 0
5765 ...
2121 # CHECK-NEXT: tracksSubRegLiveness: false
2222 # CHECK: ...
2323 name: foo
24 body:
25 - id: 0
2426 ...
2527 ---
2628 # CHECK: name: bar
3234 isSSA: false
3335 tracksRegLiveness: true
3436 tracksSubRegLiveness: true
37 body:
38 - id: 0
3539 ...