From dc6d65201dc995bdb00b76a548d9463642be7a5c Mon Sep 17 00:00:00 2001 From: Alex Lorenz Date: Fri, 19 Jun 2015 20:12:03 +0000 Subject: [PATCH] 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240174 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/MIRParser/MIRParser.cpp | 4 +++- .../MIR/machine-basic-block-unknown-name.mir | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 test/CodeGen/MIR/machine-basic-block-unknown-name.mir diff --git a/lib/CodeGen/MIRParser/MIRParser.cpp b/lib/CodeGen/MIRParser/MIRParser.cpp index 20d7f815655..1fef3f6dcb3 100644 --- a/lib/CodeGen/MIRParser/MIRParser.cpp +++ b/lib/CodeGen/MIRParser/MIRParser.cpp @@ -212,7 +212,9 @@ bool MIRParserImpl::initializeMachineFunction(MachineFunction &MF) { if (!YamlMBB.Name.empty()) { BB = dyn_cast_or_null( 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); diff --git a/test/CodeGen/MIR/machine-basic-block-unknown-name.mir b/test/CodeGen/MIR/machine-basic-block-unknown-name.mir new file mode 100644 index 00000000000..4c363c69edb --- /dev/null +++ b/test/CodeGen/MIR/machine-basic-block-unknown-name.mir @@ -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 +... -- 2.34.1