diff options
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/lib/CodeGen/MIRParser/MIRParser.cpp | 3 | ||||
-rw-r--r-- | llvm/test/CodeGen/MIR/machine-function-redefinition-error.mir | 10 |
2 files changed, 13 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp index 69ecb923ed7..19e845fc01f 100644 --- a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp +++ b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp @@ -156,6 +156,9 @@ bool MIRParserImpl::parseMachineFunction(yaml::Input &In) { if (In.error()) return true; auto FunctionName = MF->Name; + if (Functions.find(FunctionName) != Functions.end()) + return error(Twine("redefinition of machine function '") + FunctionName + + "'"); Functions.insert(std::make_pair(FunctionName, std::move(MF))); return false; } diff --git a/llvm/test/CodeGen/MIR/machine-function-redefinition-error.mir b/llvm/test/CodeGen/MIR/machine-function-redefinition-error.mir new file mode 100644 index 00000000000..be84161b563 --- /dev/null +++ b/llvm/test/CodeGen/MIR/machine-function-redefinition-error.mir @@ -0,0 +1,10 @@ +# RUN: not llc -start-after branch-folder -stop-after branch-folder -o /dev/null %s 2>&1 | FileCheck %s +# This test ensures that the machine function errors are reported correctly. + +--- +name: foo +... +--- +# CHECK: redefinition of machine function 'foo' +name: foo +... |