From: Alex Lorenz Date: Mon, 15 Jun 2015 22:23:23 +0000 (+0000) Subject: MIR Serialization: Report an error when machine functions have the same name. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=185789e9a04624d50638f1eb04661672b7323e9c;p=oota-llvm.git MIR Serialization: Report an error when machine functions have the same name. This commit reports an error when the MIR parser encounters a machine function with the name that is the same as the name of a different machine function. Reviewers: Duncan P. N. Exon Smith Differential Revision: http://reviews.llvm.org/D10130 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239774 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/MIRParser/MIRParser.cpp b/lib/CodeGen/MIRParser/MIRParser.cpp index 69ecb923ed7..19e845fc01f 100644 --- a/lib/CodeGen/MIRParser/MIRParser.cpp +++ b/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/test/CodeGen/MIR/machine-function-redefinition-error.mir b/test/CodeGen/MIR/machine-function-redefinition-error.mir new file mode 100644 index 00000000000..be84161b563 --- /dev/null +++ b/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 +...