Index: llvm/trunk/lib/CodeGen/MIRParser/MIRParser.cpp =================================================================== --- llvm/trunk/lib/CodeGen/MIRParser/MIRParser.cpp +++ llvm/trunk/lib/CodeGen/MIRParser/MIRParser.cpp @@ -173,6 +173,9 @@ 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; } Index: llvm/trunk/test/CodeGen/MIR/machine-function-missing-function.mir =================================================================== --- llvm/trunk/test/CodeGen/MIR/machine-function-missing-function.mir +++ llvm/trunk/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 +...