[llvm] 1aeb331 - [TableGen] Detect multiple Processors with the same name.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 28 22:55:07 PST 2022


Author: Craig Topper
Date: 2022-01-28T22:53:51-08:00
New Revision: 1aeb3314d8d77040527accc44aaf9d3959ac1f20

URL: https://github.com/llvm/llvm-project/commit/1aeb3314d8d77040527accc44aaf9d3959ac1f20
DIFF: https://github.com/llvm/llvm-project/commit/1aeb3314d8d77040527accc44aaf9d3959ac1f20.diff

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

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.

Reviewed By: RKSimon, spatel

Differential Revision: https://reviews.llvm.org/D118497

Added: 
    

Modified: 
    llvm/utils/TableGen/CodeGenSchedule.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/utils/TableGen/CodeGenSchedule.cpp b/llvm/utils/TableGen/CodeGenSchedule.cpp
index 7c1c37f7b370..9548dca84f5f 100644
--- a/llvm/utils/TableGen/CodeGenSchedule.cpp
+++ b/llvm/utils/TableGen/CodeGenSchedule.cpp
@@ -521,6 +521,15 @@ void CodeGenSchedModels::collectProcModels() {
   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);
 


        


More information about the llvm-commits mailing list