[PATCH] MIR Serialization: Report an error when machine functions have the same name.

Alex Lorenz arphaman at gmail.com
Mon Jun 15 15:27:52 PDT 2015


REPOSITORY
  rL LLVM

http://reviews.llvm.org/D10130

Files:
  llvm/trunk/lib/CodeGen/MIRParser/MIRParser.cpp
  llvm/trunk/test/CodeGen/MIR/machine-function-redefinition-error.mir

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

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D10130.27723.patch
Type: text/x-patch
Size: 1161 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150615/0c1ad352/attachment.bin>


More information about the llvm-commits mailing list