summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorAlex Lorenz <arphaman@gmail.com>2015-07-09 21:21:33 +0000
committerAlex Lorenz <arphaman@gmail.com>2015-07-09 21:21:33 +0000
commitc8704b02df54ff109f3fe28798aed5ff8b8ecb29 (patch)
tree719148d7f61da0821d7e4fb85c8c9dde785644ad /llvm
parentdcb9f0907f15c5a660cf8f9ffe315015af5fcaff (diff)
downloadbcm5719-llvm-c8704b02df54ff109f3fe28798aed5ff8b8ecb29.tar.gz
bcm5719-llvm-c8704b02df54ff109f3fe28798aed5ff8b8ecb29.zip
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. llvm-svn: 241862
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/CodeGen/MIRParser/MIRParser.cpp3
-rw-r--r--llvm/test/CodeGen/MIR/llvmIR.mir2
-rw-r--r--llvm/test/CodeGen/MIR/llvmIRMissing.mir2
-rw-r--r--llvm/test/CodeGen/MIR/machine-function-missing-body-error.mir15
-rw-r--r--llvm/test/CodeGen/MIR/machine-function-missing-function.mir4
-rw-r--r--llvm/test/CodeGen/MIR/machine-function-missing-name.mir4
-rw-r--r--llvm/test/CodeGen/MIR/machine-function.mir8
-rw-r--r--llvm/test/CodeGen/MIR/register-info.mir4
8 files changed, 42 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
index e505ab4baeb..e5ba0322235 100644
--- a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
+++ b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
@@ -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;
diff --git a/llvm/test/CodeGen/MIR/llvmIR.mir b/llvm/test/CodeGen/MIR/llvmIR.mir
index 4d7fde240c5..3c084ad7d39 100644
--- a/llvm/test/CodeGen/MIR/llvmIR.mir
+++ b/llvm/test/CodeGen/MIR/llvmIR.mir
@@ -32,4 +32,6 @@
...
---
name: foo
+body:
+ - id: 0
...
diff --git a/llvm/test/CodeGen/MIR/llvmIRMissing.mir b/llvm/test/CodeGen/MIR/llvmIRMissing.mir
index 83d846ba44c..80cea5a6fda 100644
--- a/llvm/test/CodeGen/MIR/llvmIRMissing.mir
+++ b/llvm/test/CodeGen/MIR/llvmIRMissing.mir
@@ -4,4 +4,6 @@
---
# CHECK: name: foo
name: foo
+body:
+ - id: 0
...
diff --git a/llvm/test/CodeGen/MIR/machine-function-missing-body-error.mir b/llvm/test/CodeGen/MIR/machine-function-missing-body-error.mir
new file mode 100644
index 00000000000..0dc7477f627
--- /dev/null
+++ b/llvm/test/CodeGen/MIR/machine-function-missing-body-error.mir
@@ -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
+...
diff --git a/llvm/test/CodeGen/MIR/machine-function-missing-function.mir b/llvm/test/CodeGen/MIR/machine-function-missing-function.mir
index eed4142d659..424c34aae84 100644
--- a/llvm/test/CodeGen/MIR/machine-function-missing-function.mir
+++ b/llvm/test/CodeGen/MIR/machine-function-missing-function.mir
@@ -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
...
diff --git a/llvm/test/CodeGen/MIR/machine-function-missing-name.mir b/llvm/test/CodeGen/MIR/machine-function-missing-name.mir
index b16156e54bd..a868a65d35f 100644
--- a/llvm/test/CodeGen/MIR/machine-function-missing-name.mir
+++ b/llvm/test/CodeGen/MIR/machine-function-missing-name.mir
@@ -16,7 +16,11 @@
---
# CHECK: [[@LINE+1]]:1: missing required key 'name'
nme: foo
+body:
+ - id: 0
...
---
name: bar
+body:
+ - id: 0
...
diff --git a/llvm/test/CodeGen/MIR/machine-function.mir b/llvm/test/CodeGen/MIR/machine-function.mir
index 8f053adc22b..afd10ab02c2 100644
--- a/llvm/test/CodeGen/MIR/machine-function.mir
+++ b/llvm/test/CodeGen/MIR/machine-function.mir
@@ -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
...
diff --git a/llvm/test/CodeGen/MIR/register-info.mir b/llvm/test/CodeGen/MIR/register-info.mir
index c01997b4685..9585faa9622 100644
--- a/llvm/test/CodeGen/MIR/register-info.mir
+++ b/llvm/test/CodeGen/MIR/register-info.mir
@@ -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
...
OpenPOWER on IntegriCloud