[PATCH] D118497: [TableGen] Detect multiple Processors with the same name.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 28 11:06:04 PST 2022


craig.topper created this revision.
craig.topper added reviewers: RKSimon, arsenm, spatel.
craig.topper requested review of this revision.
Herald added a subscriber: wdng.
Herald added a project: LLVM.

Due to a bad merge we ended up with duplicate entries in our
downstream repo. I was surprised that nothing caught it. I wrote
this check so I could fix our downstream repo and figured I might
as well share it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D118497

Files:
  llvm/utils/TableGen/CodeGenSchedule.cpp


Index: llvm/utils/TableGen/CodeGenSchedule.cpp
===================================================================
--- llvm/utils/TableGen/CodeGenSchedule.cpp
+++ llvm/utils/TableGen/CodeGenSchedule.cpp
@@ -521,6 +521,15 @@
   RecVec ProcRecords = Records.getAllDerivedDefinitions("Processor");
   llvm::sort(ProcRecords, LessRecordFieldName());
 
+  // Check for duplicated names.
+  auto I = std::adjacent_find(ProcRecords.begin(), ProcRecords.end(),
+                              [](const Record *Rec1, const Record *Rec2) {
+    return Rec1->getValueAsString("Name") == Rec2->getValueAsString("Name");
+  });
+  if (I != ProcRecords.end())
+    PrintFatalError((*I)->getLoc(), "Duplicate processor name " +
+                    (*I)->getValueAsString("Name"));
+
   // Reserve space because we can. Reallocation would be ok.
   ProcModels.reserve(ProcRecords.size()+1);
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118497.404098.patch
Type: text/x-patch
Size: 877 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220128/567da27e/attachment.bin>


More information about the llvm-commits mailing list