Skip to content

Commit

Permalink
MIR Serialization: Report an error when machine functions have the sa…
Browse files Browse the repository at this point in the history
…me 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

llvm-svn: 239774
  • Loading branch information
hyp committed Jun 15, 2015
1 parent 0ff92e6 commit fe2aa97
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions llvm/lib/CodeGen/MIRParser/MIRParser.cpp
Expand Up @@ -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;
}
Expand Down
10 changes: 10 additions & 0 deletions 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
...

0 comments on commit fe2aa97

Please sign in to comment.