llvm.org GIT mirror llvm / b86967b
MIR: Allow parsing of empty machine functions If you run llc -stop-after=codegenprepare and feed the resulting MIR to llc -start-after=codegenprepare, you'll have an empty machine function since we haven't run any isel yet. Of course, this only works if the MIRParser believes you that this is okay. This is essentially a revert of r241862 with a fix for the problem it was papering over. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299975 91177308-0d34-0410-b5e6-96231b3b80d8 Justin Bogner 3 years ago
10 changed file(s) with 21 addition(s) and 46 deletion(s). Raw diff Collapse all Expand all
366366 }
367367 PFS.SM = &SM;
368368
369 if (MF.empty())
370 return error(Twine("machine function '") + Twine(MF.getName()) +
371 "' requires at least one machine basic block in its body");
372369 // Initialize the frame information after creating all the MBBs so that the
373370 // MBB references in the frame information can be resolved.
374371 if (initializeFrameInfo(PFS, YamlMF))
527527 lastIndex = SlotIndex();
528528 regsReserved = MRI->getReservedRegs();
529529
530 markReachable(&MF->front());
530 if (!MF->empty())
531 markReachable(&MF->front());
531532
532533 // Build a set of the basic blocks in the function.
533534 FunctionBlocks.clear();
547548 // Check that the register use lists are sane.
548549 MRI->verifyUseLists();
549550
550 verifyStackFrame();
551 if (!MF->empty())
552 verifyStackFrame();
551553 }
552554
553555 // Does iterator point to a and b as the first two elements?
2727 IfUnequal:
2828 ret i32 0
2929 }
30
30
3131 ...
3232 ---
3333 name: foo
34 body: |
35 bb.0:
3634 ...
33 ---
44 # CHECK: name: foo
55 name: foo
6 body: |
7 bb.0:
86 ...
+0
-15
test/CodeGen/MIR/Generic/machine-function-missing-body-error.mir less more
None # RUN: not llc -run-pass none -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 ...
0 # RUN: llc -run-pass none -o - %s | FileCheck %s
1 # This test ensures that the MIR parser accepts files with llvm IR but
2 # no machine function body.
3
4 --- |
5 ; CHECK: define i32 @foo()
6 define i32 @foo() {
7 ret i32 0
8 }
9
10 ...
11 ---
12 # CHECK: name: foo
13 name: foo
14 ...
1111 ...
1212 ---
1313 name: foo
14 body: |
15 bb.0:
1614 ...
1715 ---
1816 # CHECK: function 'faa' isn't defined in the provided LLVM IR
1917 name: faa
20 body: |
21 bb.0:
2218 ...
1515 ---
1616 # CHECK: [[@LINE+1]]:1: missing required key 'name'
1717 nme: foo
18 body: |
19 bb.0:
2018 ...
2119 ---
2220 name: bar
23 body: |
24 bb.0:
2521 ...
1717 define i32 @func2() {
1818 ret i32 0
1919 }
20
20
2121 ...
2222 ---
2323 # CHECK: name: foo
2525 # CHECK-NEXT: exposesReturnsTwice: false
2626 # CHECK: ...
2727 name: foo
28 body: |
29 bb.0:
3028 ...
3129 ---
3230 # CHECK: name: bar
3432 # CHECK-NEXT: exposesReturnsTwice: false
3533 # CHECK: ...
3634 name: bar
37 body: |
38 bb.0:
3935 ...
4036 ---
4137 # CHECK: name: func
4440 # CHECK: ...
4541 name: func
4642 alignment: 8
47 body: |
48 bb.0:
4943 ...
5044 ---
5145 # CHECK: name: func2
5549 name: func2
5650 alignment: 16
5751 exposesReturnsTwice: true
58 body: |
59 bb.0:
6052 ...
1919 # CHECK: tracksRegLiveness: false
2020 # CHECK: ...
2121 name: foo
22 body: |
23 bb.0:
2422 ...
2523 ---
2624 # CHECK: name: bar
2826 # CHECK: ...
2927 name: bar
3028 tracksRegLiveness: true
31 body: |
32 bb.0:
3329 ...