[llvm] r241862 - MIR Parser: Report an error when parsing machine function with an empty body.
Alex Lorenz
arphaman at gmail.com
Thu Jul 9 14:21:34 PDT 2015
Author: arphaman
Date: Thu Jul 9 16:21:33 2015
New Revision: 241862
URL: http://llvm.org/viewvc/llvm-project?rev=241862&view=rev
Log:
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.
Added:
llvm/trunk/test/CodeGen/MIR/machine-function-missing-body-error.mir
Modified:
llvm/trunk/lib/CodeGen/MIRParser/MIRParser.cpp
llvm/trunk/test/CodeGen/MIR/llvmIR.mir
llvm/trunk/test/CodeGen/MIR/llvmIRMissing.mir
llvm/trunk/test/CodeGen/MIR/machine-function-missing-function.mir
llvm/trunk/test/CodeGen/MIR/machine-function-missing-name.mir
llvm/trunk/test/CodeGen/MIR/machine-function.mir
llvm/trunk/test/CodeGen/MIR/register-info.mir
Modified: llvm/trunk/lib/CodeGen/MIRParser/MIRParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MIRParser/MIRParser.cpp?rev=241862&r1=241861&r2=241862&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MIRParser/MIRParser.cpp (original)
+++ llvm/trunk/lib/CodeGen/MIRParser/MIRParser.cpp Thu Jul 9 16:21:33 2015
@@ -275,6 +275,9 @@ bool MIRParserImpl::initializeMachineFun
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;
Modified: llvm/trunk/test/CodeGen/MIR/llvmIR.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MIR/llvmIR.mir?rev=241862&r1=241861&r2=241862&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/MIR/llvmIR.mir (original)
+++ llvm/trunk/test/CodeGen/MIR/llvmIR.mir Thu Jul 9 16:21:33 2015
@@ -32,4 +32,6 @@
...
---
name: foo
+body:
+ - id: 0
...
Modified: llvm/trunk/test/CodeGen/MIR/llvmIRMissing.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MIR/llvmIRMissing.mir?rev=241862&r1=241861&r2=241862&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/MIR/llvmIRMissing.mir (original)
+++ llvm/trunk/test/CodeGen/MIR/llvmIRMissing.mir Thu Jul 9 16:21:33 2015
@@ -4,4 +4,6 @@
---
# CHECK: name: foo
name: foo
+body:
+ - id: 0
...
Added: llvm/trunk/test/CodeGen/MIR/machine-function-missing-body-error.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MIR/machine-function-missing-body-error.mir?rev=241862&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/MIR/machine-function-missing-body-error.mir (added)
+++ llvm/trunk/test/CodeGen/MIR/machine-function-missing-body-error.mir Thu Jul 9 16:21:33 2015
@@ -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
+...
Modified: llvm/trunk/test/CodeGen/MIR/machine-function-missing-function.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MIR/machine-function-missing-function.mir?rev=241862&r1=241861&r2=241862&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/MIR/machine-function-missing-function.mir (original)
+++ llvm/trunk/test/CodeGen/MIR/machine-function-missing-function.mir Thu Jul 9 16:21:33 2015
@@ -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
...
Modified: llvm/trunk/test/CodeGen/MIR/machine-function-missing-name.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MIR/machine-function-missing-name.mir?rev=241862&r1=241861&r2=241862&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/MIR/machine-function-missing-name.mir (original)
+++ llvm/trunk/test/CodeGen/MIR/machine-function-missing-name.mir Thu Jul 9 16:21:33 2015
@@ -16,7 +16,11 @@
---
# CHECK: [[@LINE+1]]:1: missing required key 'name'
nme: foo
+body:
+ - id: 0
...
---
name: bar
+body:
+ - id: 0
...
Modified: llvm/trunk/test/CodeGen/MIR/machine-function.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MIR/machine-function.mir?rev=241862&r1=241861&r2=241862&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/MIR/machine-function.mir (original)
+++ llvm/trunk/test/CodeGen/MIR/machine-function.mir Thu Jul 9 16:21:33 2015
@@ -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
...
Modified: llvm/trunk/test/CodeGen/MIR/register-info.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MIR/register-info.mir?rev=241862&r1=241861&r2=241862&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/MIR/register-info.mir (original)
+++ llvm/trunk/test/CodeGen/MIR/register-info.mir Thu Jul 9 16:21:33 2015
@@ -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
...
More information about the llvm-commits
mailing list