From d8a0ff34d90f7ab98b76aff0ab875487e1ca5b69 Mon Sep 17 00:00:00 2001 From: Alex Lorenz Date: Tue, 16 Jun 2015 17:06:29 +0000 Subject: [PATCH] MIR Parser: Report an error when a machine function doesn't have a corresponding function. This commit reports an error when a machine function from a MIR file that contains LLVM IR can't find a function with the same name in the loaded LLVM IR module. Reviewers: Duncan P. N. Exon Smith Differential Revision: http://reviews.llvm.org/D10468 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239831 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/MIRParser/MIRParser.cpp | 3 +++ .../CodeGen/MIR/machine-function-missing-function.mir | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 test/CodeGen/MIR/machine-function-missing-function.mir diff --git a/lib/CodeGen/MIRParser/MIRParser.cpp b/lib/CodeGen/MIRParser/MIRParser.cpp index acd3c1130a5..8fe4c838000 100644 --- a/lib/CodeGen/MIRParser/MIRParser.cpp +++ b/lib/CodeGen/MIRParser/MIRParser.cpp @@ -173,6 +173,9 @@ bool MIRParserImpl::parseMachineFunction(yaml::Input &In, Module &M, Functions.insert(std::make_pair(FunctionName, std::move(MF))); if (NoLLVMIR) createDummyFunction(FunctionName, M); + else if (!M.getFunction(FunctionName)) + return error(Twine("function '") + FunctionName + + "' isn't defined in the provided LLVM IR"); return false; } diff --git a/test/CodeGen/MIR/machine-function-missing-function.mir b/test/CodeGen/MIR/machine-function-missing-function.mir new file mode 100644 index 00000000000..eed4142d659 --- /dev/null +++ b/test/CodeGen/MIR/machine-function-missing-function.mir @@ -0,0 +1,19 @@ +# 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 when the mir file has LLVM IR and +# one of the machine functions has a name that doesn't match any function in +# the LLVM IR. + +--- | + + define i32 @foo() { + ret i32 0 + } + +... +--- +name: foo +... +--- +# CHECK: function 'faa' isn't defined in the provided LLVM IR +name: faa +... -- 2.11.0