[llvm] r240174 - MIR Parser: report an error when a basic block isn't found.

Alex Lorenz arphaman at gmail.com
Fri Jun 19 13:12:04 PDT 2015


Author: arphaman
Date: Fri Jun 19 15:12:03 2015
New Revision: 240174

URL: http://llvm.org/viewvc/llvm-project?rev=240174&view=rev
Log:
MIR Parser: report an error when a basic block isn't found.

This commit reports an error when the MIR parser can't find
a basic block with the machine basic block's name.

Added:
    llvm/trunk/test/CodeGen/MIR/machine-basic-block-unknown-name.mir
Modified:
    llvm/trunk/lib/CodeGen/MIRParser/MIRParser.cpp

Modified: llvm/trunk/lib/CodeGen/MIRParser/MIRParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MIRParser/MIRParser.cpp?rev=240174&r1=240173&r2=240174&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MIRParser/MIRParser.cpp (original)
+++ llvm/trunk/lib/CodeGen/MIRParser/MIRParser.cpp Fri Jun 19 15:12:03 2015
@@ -212,7 +212,9 @@ bool MIRParserImpl::initializeMachineFun
     if (!YamlMBB.Name.empty()) {
       BB = dyn_cast_or_null<BasicBlock>(
           F.getValueSymbolTable().lookup(YamlMBB.Name));
-      // TODO: Report an error if a basic block isn't found.
+      if (!BB)
+        return error(Twine("basic block '") + YamlMBB.Name +
+                     "' is not defined in the function '" + MF.getName() + "'");
     }
     auto *MBB = MF.CreateMachineBasicBlock(BB);
     MF.insert(MF.end(), MBB);

Added: llvm/trunk/test/CodeGen/MIR/machine-basic-block-unknown-name.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MIR/machine-basic-block-unknown-name.mir?rev=240174&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/MIR/machine-basic-block-unknown-name.mir (added)
+++ llvm/trunk/test/CodeGen/MIR/machine-basic-block-unknown-name.mir Fri Jun 19 15:12:03 2015
@@ -0,0 +1,18 @@
+# RUN: not llc -start-after branch-folder -stop-after branch-folder -o /dev/null %s 2>&1 | FileCheck %s
+# This test ensures that an error is reported whenever the MIR parser can't find
+# a basic block with the machine basis block's name.
+
+--- |
+
+  define i32 @foo() {
+  entry:
+    ret i32 0
+  }
+
+...
+---
+name:            foo
+body:
+  # CHECK: basic block 'entrie' is not defined in the function 'foo'
+  - name:         entrie
+...





More information about the llvm-commits mailing list