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
This commit is contained in:
Alex Lorenz 2015-07-09 21:21:33 +00:00
parent 847c023a2e
commit ccba68af82
8 changed files with 42 additions and 0 deletions

View File

@ -275,6 +275,9 @@ bool MIRParserImpl::initializeMachineFunction(MachineFunction &MF) {
Twine(YamlMBB.ID));
}
if (YamlMF.BasicBlocks.empty())
return error(Twine("machine function '") + Twine(MF.getName()) +
"' requires at least one machine basic block in its body");
// Initialize the machine basic blocks after creating them all so that the
// machine instructions parser can resolve the MBB references.
unsigned I = 0;

View File

@ -32,4 +32,6 @@
...
---
name: foo
body:
- id: 0
...

View File

@ -4,4 +4,6 @@
---
# CHECK: name: foo
name: foo
body:
- id: 0
...

View File

@ -0,0 +1,15 @@
# RUN: not llc -start-after branch-folder -stop-after branch-folder -o /dev/null %s 2>&1 | FileCheck %s
# This test ensures that the MIR parser reports an error when it encounters a
# machine function with an empty body.
--- |
define i32 @foo() {
ret i32 0
}
...
---
# CHECK: machine function 'foo' requires at least one machine basic block in its body
name: foo
...

View File

@ -12,8 +12,12 @@
...
---
name: foo
body:
- id: 0
...
---
# CHECK: function 'faa' isn't defined in the provided LLVM IR
name: faa
body:
- id: 0
...

View File

@ -16,7 +16,11 @@
---
# CHECK: [[@LINE+1]]:1: missing required key 'name'
nme: foo
body:
- id: 0
...
---
name: bar
body:
- id: 0
...

View File

@ -27,6 +27,8 @@
# CHECK-NEXT: hasInlineAsm: false
# CHECK: ...
name: foo
body:
- id: 0
...
---
# CHECK: name: bar
@ -35,6 +37,8 @@ name: foo
# CHECK-NEXT: hasInlineAsm: false
# CHECK: ...
name: bar
body:
- id: 0
...
---
# CHECK: name: func
@ -44,6 +48,8 @@ name: bar
# CHECK: ...
name: func
alignment: 8
body:
- id: 0
...
---
# CHECK: name: func2
@ -55,4 +61,6 @@ name: func2
alignment: 16
exposesReturnsTwice: true
hasInlineAsm: true
body:
- id: 0
...

View File

@ -22,6 +22,8 @@
# CHECK-NEXT: tracksSubRegLiveness: false
# CHECK: ...
name: foo
body:
- id: 0
...
---
# CHECK: name: bar
@ -33,4 +35,6 @@ name: bar
isSSA: false
tracksRegLiveness: true
tracksSubRegLiveness: true
body:
- id: 0
...