Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LLVM][TableGen] Change SeachableTableEmitter to use const RecordKeeper #110032

Merged
merged 1 commit into from
Sep 30, 2024

Conversation

jurahul
Copy link
Contributor

@jurahul jurahul commented Sep 25, 2024

Change SeachableTableEmitter to use const RecordKeeper.
Also change RecordRecTy to use const Record pointers for its classes.

This is a part of effort to have better const correctness in TableGen backends:

https://discourse.llvm.org/t/psa-planned-changes-to-tablegen-getallderiveddefinitions-api-potential-downstream-breakages/81089

@jurahul jurahul force-pushed the const_record_searchable_table_emitter branch from 31c7c55 to 934b0bd Compare September 25, 2024 22:38
@jurahul jurahul marked this pull request as ready for review September 26, 2024 00:33
@jurahul jurahul requested review from arsenm and removed request for antiagainst and kuhar September 26, 2024 00:33
@llvmbot llvmbot added clang Clang issues not falling into any other category mlir:core MLIR Core Infrastructure tablegen mlir:spirv mlir labels Sep 26, 2024
@llvmbot
Copy link
Member

llvmbot commented Sep 26, 2024

@llvm/pr-subscribers-mlir-spirv
@llvm/pr-subscribers-mlir
@llvm/pr-subscribers-tablegen

@llvm/pr-subscribers-clang

Author: Rahul Joshi (jurahul)

Changes

Change SeachableTableEmitter to use const RecordKeeper.
Also change RecordRecTy to use const Record pointers for its classes.

This is a part of effort to have better const correctness in TableGen backends:

https://discourse.llvm.org/t/psa-planned-changes-to-tablegen-getallderiveddefinitions-api-potential-downstream-breakages/81089


Patch is 26.79 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/110032.diff

7 Files Affected:

  • (modified) clang/utils/TableGen/ClangAttrEmitter.cpp (+1-1)
  • (modified) llvm/include/llvm/TableGen/Record.h (+12-11)
  • (modified) llvm/lib/TableGen/Record.cpp (+25-25)
  • (modified) llvm/lib/TableGen/TGParser.cpp (+1-1)
  • (modified) llvm/utils/TableGen/SearchableTableEmitter.cpp (+73-65)
  • (modified) mlir/tools/mlir-tblgen/OmpOpGen.cpp (+1-1)
  • (modified) mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp (+3-3)
diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp b/clang/utils/TableGen/ClangAttrEmitter.cpp
index 87be48c215e230..7f950c3b08a4b0 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -1866,7 +1866,7 @@ static LateAttrParseKind getLateAttrParseKind(const Record *Attr) {
   auto *LAPK = Attr->getValueAsDef(LateParsedStr);
 
   // Typecheck the `LateParsed` field.
-  SmallVector<Record *, 1> SuperClasses;
+  SmallVector<const Record *, 1> SuperClasses;
   LAPK->getDirectSuperClasses(SuperClasses);
   if (SuperClasses.size() != 1)
     PrintFatalError(Attr, "Field `" + Twine(LateParsedStr) +
diff --git a/llvm/include/llvm/TableGen/Record.h b/llvm/include/llvm/TableGen/Record.h
index 4cd73c3f675527..b68fff605d12dd 100644
--- a/llvm/include/llvm/TableGen/Record.h
+++ b/llvm/include/llvm/TableGen/Record.h
@@ -226,8 +226,9 @@ class DagRecTy : public RecTy {
 ///
 /// The list of superclasses is non-redundant, i.e. only contains classes that
 /// are not the superclass of some other listed class.
-class RecordRecTy final : public RecTy, public FoldingSetNode,
-                          public TrailingObjects<RecordRecTy, Record *> {
+class RecordRecTy final : public RecTy,
+                          public FoldingSetNode,
+                          public TrailingObjects<RecordRecTy, const Record *> {
   friend class Record;
   friend detail::RecordKeeperImpl;
 
@@ -248,23 +249,23 @@ class RecordRecTy final : public RecTy, public FoldingSetNode,
   }
 
   /// Get the record type with the given non-redundant list of superclasses.
-  static RecordRecTy *get(RecordKeeper &RK, ArrayRef<Record *> Classes);
-  static RecordRecTy *get(Record *Class);
+  static RecordRecTy *get(RecordKeeper &RK, ArrayRef<const Record *> Classes);
+  static RecordRecTy *get(const Record *Class);
 
   void Profile(FoldingSetNodeID &ID) const;
 
-  ArrayRef<Record *> getClasses() const {
-    return ArrayRef(getTrailingObjects<Record *>(), NumClasses);
+  ArrayRef<const Record *> getClasses() const {
+    return ArrayRef(getTrailingObjects<const Record *>(), NumClasses);
   }
 
-  using const_record_iterator = Record * const *;
+  using const_record_iterator = const Record *const *;
 
   const_record_iterator classes_begin() const { return getClasses().begin(); }
   const_record_iterator classes_end() const { return getClasses().end(); }
 
   std::string getAsString() const override;
 
-  bool isSubClassOf(Record *Class) const;
+  bool isSubClassOf(const Record *Class) const;
   bool typeIsConvertibleTo(const RecTy *RHS) const override;
 
   bool typeIsA(const RecTy *RHS) const override;
@@ -1556,7 +1557,7 @@ class RecordVal {
   bool IsUsed = false;
 
   /// Reference locations to this record value.
-  SmallVector<SMRange> ReferenceLocs;
+  mutable SmallVector<SMRange> ReferenceLocs;
 
 public:
   RecordVal(Init *N, RecTy *T, FieldKind K);
@@ -1605,7 +1606,7 @@ class RecordVal {
   bool setValue(Init *V, SMLoc NewLoc);
 
   /// Add a reference to this record value.
-  void addReferenceLoc(SMRange Loc) { ReferenceLocs.push_back(Loc); }
+  void addReferenceLoc(SMRange Loc) const { ReferenceLocs.push_back(Loc); }
 
   /// Return the references of this record value.
   ArrayRef<SMRange> getReferenceLocs() const { return ReferenceLocs; }
@@ -1763,7 +1764,7 @@ class Record {
   bool hasDirectSuperClass(const Record *SuperClass) const;
 
   /// Append the direct superclasses of this record to Classes.
-  void getDirectSuperClasses(SmallVectorImpl<Record *> &Classes) const;
+  void getDirectSuperClasses(SmallVectorImpl<const Record *> &Classes) const;
 
   bool isTemplateArg(Init *Name) const {
     return llvm::is_contained(TemplateArgs, Name);
diff --git a/llvm/lib/TableGen/Record.cpp b/llvm/lib/TableGen/Record.cpp
index 0f99b4a13d2f95..2973ef40642554 100644
--- a/llvm/lib/TableGen/Record.cpp
+++ b/llvm/lib/TableGen/Record.cpp
@@ -226,22 +226,22 @@ std::string DagRecTy::getAsString() const {
 }
 
 static void ProfileRecordRecTy(FoldingSetNodeID &ID,
-                               ArrayRef<Record *> Classes) {
+                               ArrayRef<const Record *> Classes) {
   ID.AddInteger(Classes.size());
-  for (Record *R : Classes)
+  for (const Record *R : Classes)
     ID.AddPointer(R);
 }
 
 RecordRecTy *RecordRecTy::get(RecordKeeper &RK,
-                              ArrayRef<Record *> UnsortedClasses) {
+                              ArrayRef<const Record *> UnsortedClasses) {
   detail::RecordKeeperImpl &RKImpl = RK.getImpl();
   if (UnsortedClasses.empty())
     return &RKImpl.AnyRecord;
 
   FoldingSet<RecordRecTy> &ThePool = RKImpl.RecordTypePool;
 
-  SmallVector<Record *, 4> Classes(UnsortedClasses);
-  llvm::sort(Classes, [](Record *LHS, Record *RHS) {
+  SmallVector<const Record *, 4> Classes(UnsortedClasses);
+  llvm::sort(Classes, [](const Record *LHS, const Record *RHS) {
     return LHS->getNameInitAsString() < RHS->getNameInitAsString();
   });
 
@@ -263,16 +263,16 @@ RecordRecTy *RecordRecTy::get(RecordKeeper &RK,
 #endif
 
   void *Mem = RKImpl.Allocator.Allocate(
-      totalSizeToAlloc<Record *>(Classes.size()), alignof(RecordRecTy));
+      totalSizeToAlloc<const Record *>(Classes.size()), alignof(RecordRecTy));
   RecordRecTy *Ty = new (Mem) RecordRecTy(RK, Classes.size());
   std::uninitialized_copy(Classes.begin(), Classes.end(),
-                          Ty->getTrailingObjects<Record *>());
+                          Ty->getTrailingObjects<const Record *>());
   ThePool.InsertNode(Ty, IP);
   return Ty;
 }
-RecordRecTy *RecordRecTy::get(Record *Class) {
+RecordRecTy *RecordRecTy::get(const Record *Class) {
   assert(Class && "unexpected null class");
-  return get(Class->getRecords(), Class);
+  return get(Class->getRecords(), {Class});
 }
 
 void RecordRecTy::Profile(FoldingSetNodeID &ID) const {
@@ -285,7 +285,7 @@ std::string RecordRecTy::getAsString() const {
 
   std::string Str = "{";
   bool First = true;
-  for (Record *R : getClasses()) {
+  for (const Record *R : getClasses()) {
     if (!First)
       Str += ", ";
     First = false;
@@ -295,11 +295,10 @@ std::string RecordRecTy::getAsString() const {
   return Str;
 }
 
-bool RecordRecTy::isSubClassOf(Record *Class) const {
-  return llvm::any_of(getClasses(), [Class](Record *MySuperClass) {
-                                      return MySuperClass == Class ||
-                                             MySuperClass->isSubClassOf(Class);
-                                    });
+bool RecordRecTy::isSubClassOf(const Record *Class) const {
+  return llvm::any_of(getClasses(), [Class](const Record *MySuperClass) {
+    return MySuperClass == Class || MySuperClass->isSubClassOf(Class);
+  });
 }
 
 bool RecordRecTy::typeIsConvertibleTo(const RecTy *RHS) const {
@@ -310,9 +309,9 @@ bool RecordRecTy::typeIsConvertibleTo(const RecTy *RHS) const {
   if (!RTy)
     return false;
 
-  return llvm::all_of(RTy->getClasses(), [this](Record *TargetClass) {
-                                           return isSubClassOf(TargetClass);
-                                         });
+  return llvm::all_of(RTy->getClasses(), [this](const Record *TargetClass) {
+    return isSubClassOf(TargetClass);
+  });
 }
 
 bool RecordRecTy::typeIsA(const RecTy *RHS) const {
@@ -320,11 +319,11 @@ bool RecordRecTy::typeIsA(const RecTy *RHS) const {
 }
 
 static RecordRecTy *resolveRecordTypes(RecordRecTy *T1, RecordRecTy *T2) {
-  SmallVector<Record *, 4> CommonSuperClasses;
-  SmallVector<Record *, 4> Stack(T1->getClasses());
+  SmallVector<const Record *, 4> CommonSuperClasses;
+  SmallVector<const Record *, 4> Stack(T1->getClasses());
 
   while (!Stack.empty()) {
-    Record *R = Stack.pop_back_val();
+    const Record *R = Stack.pop_back_val();
 
     if (T2->isSubClassOf(R)) {
       CommonSuperClasses.push_back(R);
@@ -2162,8 +2161,8 @@ std::string ExistsOpInit::getAsString() const {
 
 RecTy *TypedInit::getFieldType(StringInit *FieldName) const {
   if (RecordRecTy *RecordType = dyn_cast<RecordRecTy>(getType())) {
-    for (Record *Rec : RecordType->getClasses()) {
-      if (RecordVal *Field = Rec->getValue(FieldName))
+    for (const Record *Rec : RecordType->getClasses()) {
+      if (const RecordVal *Field = Rec->getValue(FieldName))
         return Field->getType();
     }
   }
@@ -2831,7 +2830,7 @@ void Record::checkName() {
 }
 
 RecordRecTy *Record::getType() const {
-  SmallVector<Record *, 4> DirectSCs;
+  SmallVector<const Record *, 4> DirectSCs;
   getDirectSuperClasses(DirectSCs);
   return RecordRecTy::get(TrackedRecords, DirectSCs);
 }
@@ -2882,7 +2881,8 @@ bool Record::hasDirectSuperClass(const Record *Superclass) const {
   return false;
 }
 
-void Record::getDirectSuperClasses(SmallVectorImpl<Record *> &Classes) const {
+void Record::getDirectSuperClasses(
+    SmallVectorImpl<const Record *> &Classes) const {
   ArrayRef<std::pair<Record *, SMRange>> SCs = getSuperClasses();
 
   while (!SCs.empty()) {
diff --git a/llvm/lib/TableGen/TGParser.cpp b/llvm/lib/TableGen/TGParser.cpp
index 54c9a902ec27a1..288bb8a4ed1a61 100644
--- a/llvm/lib/TableGen/TGParser.cpp
+++ b/llvm/lib/TableGen/TGParser.cpp
@@ -3004,7 +3004,7 @@ Init *TGParser::ParseValue(Record *CurRec, RecTy *ItemType, IDParseMode Mode) {
           DI->getDef()->getValue(FieldName)->addReferenceLoc(FieldNameLoc);
         } else if (auto *TI = dyn_cast<TypedInit>(Result)) {
           if (auto *RecTy = dyn_cast<RecordRecTy>(TI->getType())) {
-            for (Record *R : RecTy->getClasses())
+            for (const Record *R : RecTy->getClasses())
               if (auto *RV = R->getValue(FieldName))
                 RV->addReferenceLoc(FieldNameLoc);
           }
diff --git a/llvm/utils/TableGen/SearchableTableEmitter.cpp b/llvm/utils/TableGen/SearchableTableEmitter.cpp
index b5bf621b057383..549929d7a33820 100644
--- a/llvm/utils/TableGen/SearchableTableEmitter.cpp
+++ b/llvm/utils/TableGen/SearchableTableEmitter.cpp
@@ -48,10 +48,10 @@ struct GenericEnum {
   using Entry = std::pair<StringRef, int64_t>;
 
   std::string Name;
-  Record *Class = nullptr;
+  const Record *Class = nullptr;
   std::string PreprocessorGuard;
   std::vector<std::unique_ptr<Entry>> Entries;
-  DenseMap<Record *, Entry *> EntryMap;
+  DenseMap<const Record *, Entry *> EntryMap;
 };
 
 struct GenericField {
@@ -79,7 +79,7 @@ struct GenericTable {
   std::string PreprocessorGuard;
   std::string CppTypeName;
   SmallVector<GenericField, 2> Fields;
-  std::vector<Record *> Entries;
+  std::vector<const Record *> Entries;
 
   std::unique_ptr<SearchIndex> PrimaryKey;
   SmallVector<std::unique_ptr<SearchIndex>, 2> Indices;
@@ -94,20 +94,20 @@ struct GenericTable {
 };
 
 class SearchableTableEmitter {
-  RecordKeeper &Records;
+  const RecordKeeper &Records;
   std::unique_ptr<CodeGenTarget> Target;
   std::unique_ptr<CodeGenIntrinsicMap> Intrinsics;
   std::vector<std::unique_ptr<GenericEnum>> Enums;
-  DenseMap<Record *, GenericEnum *> EnumMap;
+  DenseMap<const Record *, GenericEnum *> EnumMap;
   std::set<std::string> PreprocessorGuards;
 
 public:
-  SearchableTableEmitter(RecordKeeper &R) : Records(R) {}
+  explicit SearchableTableEmitter(const RecordKeeper &R) : Records(R) {}
 
   void run(raw_ostream &OS);
 
 private:
-  typedef std::pair<Init *, int> SearchTableEntry;
+  typedef std::pair<const Init *, int> SearchTableEntry;
 
   enum TypeContext {
     TypeInStaticStruct,
@@ -116,15 +116,15 @@ class SearchableTableEmitter {
   };
 
   std::string primaryRepresentation(SMLoc Loc, const GenericField &Field,
-                                    Init *I) {
-    if (StringInit *SI = dyn_cast<StringInit>(I)) {
+                                    const Init *I) {
+    if (const StringInit *SI = dyn_cast<StringInit>(I)) {
       if (Field.IsCode || SI->hasCodeFormat())
         return std::string(SI->getValue());
       else
         return SI->getAsString();
-    } else if (BitsInit *BI = dyn_cast<BitsInit>(I))
+    } else if (const BitsInit *BI = dyn_cast<BitsInit>(I))
       return "0x" + utohexstr(getAsInt(BI));
-    else if (BitInit *BI = dyn_cast<BitInit>(I))
+    else if (const BitInit *BI = dyn_cast<BitInit>(I))
       return BI->getValue() ? "true" : "false";
     else if (Field.IsIntrinsic)
       return "Intrinsic::" + getIntrinsic(I).EnumName.str();
@@ -152,7 +152,8 @@ class SearchableTableEmitter {
     return Target->getIntrinsic(Def);
   }
 
-  bool compareBy(Record *LHS, Record *RHS, const SearchIndex &Index);
+  bool compareBy(const Record *LHS, const Record *RHS,
+                 const SearchIndex &Index);
 
   std::string searchableFieldType(const GenericTable &Table,
                                   const SearchIndex &Index,
@@ -163,7 +164,7 @@ class SearchableTableEmitter {
       if (Ctx == TypeInTempStruct)
         return "std::string";
       return "StringRef";
-    } else if (BitsRecTy *BI = dyn_cast<BitsRecTy>(Field.RecType)) {
+    } else if (const BitsRecTy *BI = dyn_cast<BitsRecTy>(Field.RecType)) {
       unsigned NumBits = BI->getNumBits();
       if (NumBits <= 8)
         return "uint8_t";
@@ -198,14 +199,11 @@ class SearchableTableEmitter {
   bool parseFieldType(GenericField &Field, Init *II);
   std::unique_ptr<SearchIndex>
   parseSearchIndex(GenericTable &Table, const RecordVal *RecVal, StringRef Name,
-                   const std::vector<StringRef> &Key, bool EarlyOut,
-                   bool ReturnRange);
+                   ArrayRef<StringRef> Key, bool EarlyOut, bool ReturnRange);
   void collectEnumEntries(GenericEnum &Enum, StringRef NameField,
-                          StringRef ValueField,
-                          const std::vector<Record *> &Items);
-  void collectTableEntries(GenericTable &Table,
-                           const std::vector<Record *> &Items);
-  int64_t getNumericKey(const SearchIndex &Index, Record *Rec);
+                          StringRef ValueField, ArrayRef<const Record *> Items);
+  void collectTableEntries(GenericTable &Table, ArrayRef<const Record *> Items);
+  int64_t getNumericKey(const SearchIndex &Index, const Record *Rec);
 };
 
 } // End anonymous namespace.
@@ -213,17 +211,17 @@ class SearchableTableEmitter {
 // For search indices that consists of a single field whose numeric value is
 // known, return that numeric value.
 int64_t SearchableTableEmitter::getNumericKey(const SearchIndex &Index,
-                                              Record *Rec) {
+                                              const Record *Rec) {
   assert(Index.Fields.size() == 1);
 
   // To be consistent with compareBy and primaryRepresentation elsewhere,
   // we check for IsInstruction before Enum-- these fields are not exclusive.
   if (Index.Fields[0].IsInstruction) {
-    Record *TheDef = Rec->getValueAsDef(Index.Fields[0].Name);
+    const Record *TheDef = Rec->getValueAsDef(Index.Fields[0].Name);
     return Target->getInstrIntValue(TheDef);
   }
   if (Index.Fields[0].Enum) {
-    Record *EnumEntry = Rec->getValueAsDef(Index.Fields[0].Name);
+    const Record *EnumEntry = Rec->getValueAsDef(Index.Fields[0].Name);
     return Index.Fields[0].Enum->EntryMap[EnumEntry]->second;
   }
 
@@ -232,7 +230,7 @@ int64_t SearchableTableEmitter::getNumericKey(const SearchIndex &Index,
 
 /// Less-than style comparison between \p LHS and \p RHS according to the
 /// key of \p Index.
-bool SearchableTableEmitter::compareBy(Record *LHS, Record *RHS,
+bool SearchableTableEmitter::compareBy(const Record *LHS, const Record *RHS,
                                        const SearchIndex &Index) {
   for (const auto &Field : Index.Fields) {
     Init *LHSI = LHS->getValueInit(Field.Name);
@@ -256,8 +254,8 @@ bool SearchableTableEmitter::compareBy(Record *LHS, Record *RHS,
         return false;
     } else if (Field.IsInstruction) {
       // This does not correctly compare the predefined instructions!
-      Record *LHSr = cast<DefInit>(LHSI)->getDef();
-      Record *RHSr = cast<DefInit>(RHSI)->getDef();
+      const Record *LHSr = cast<DefInit>(LHSI)->getDef();
+      const Record *RHSr = cast<DefInit>(RHSI)->getDef();
 
       bool LHSpseudo = LHSr->getValueAsBit("isPseudo");
       bool RHSpseudo = RHSr->getValueAsBit("isPseudo");
@@ -325,8 +323,8 @@ void SearchableTableEmitter::emitLookupFunction(const GenericTable &Table,
   emitLookupDeclaration(Table, Index, OS);
   OS << " {\n";
 
-  std::vector<Record *> IndexRowsStorage;
-  ArrayRef<Record *> IndexRows;
+  std::vector<const Record *> IndexRowsStorage;
+  ArrayRef<const Record *> IndexRows;
   StringRef IndexTypeName;
   StringRef IndexName;
 
@@ -346,15 +344,16 @@ void SearchableTableEmitter::emitLookupFunction(const GenericTable &Table,
 
     OS << "  static const struct IndexType Index[] = {\n";
 
-    std::vector<std::pair<Record *, unsigned>> Entries;
+    std::vector<std::pair<const Record *, unsigned>> Entries;
     Entries.reserve(Table.Entries.size());
     for (unsigned i = 0; i < Table.Entries.size(); ++i)
       Entries.emplace_back(Table.Entries[i], i);
 
-    llvm::stable_sort(Entries, [&](const std::pair<Record *, unsigned> &LHS,
-                                   const std::pair<Record *, unsigned> &RHS) {
-      return compareBy(LHS.first, RHS.first, Index);
-    });
+    llvm::stable_sort(Entries,
+                      [&](const std::pair<const Record *, unsigned> &LHS,
+                          const std::pair<const Record *, unsigned> &RHS) {
+                        return compareBy(LHS.first, RHS.first, Index);
+                      });
 
     IndexRowsStorage.reserve(Entries.size());
     for (const auto &Entry : Entries) {
@@ -552,7 +551,7 @@ void SearchableTableEmitter::emitGenericTable(const GenericTable &Table,
   // The primary data table contains all the fields defined for this map.
   OS << "constexpr " << Table.CppTypeName << " " << Table.Name << "[] = {\n";
   for (unsigned i = 0; i < Table.Entries.size(); ++i) {
-    Record *Entry = Table.Entries[i];
+    const Record *Entry = Table.Entries[i];
     OS << "  { ";
 
     ListSeparator LS;
@@ -576,18 +575,22 @@ void SearchableTableEmitter::emitGenericTable(const GenericTable &Table,
 }
 
 bool SearchableTableEmitter::parseFieldType(GenericField &Field, Init *TypeOf) {
-  if (auto Type = dyn_cast<StringInit>(TypeOf)) {
-    if (Type->getValue() == "code") {
-      Field.IsCode = true;
+  auto Type = dyn_cast<StringInit>(TypeOf);
+  if (!Type)
+    return false;
+
+  StringRef TypeStr = Type->getValue();
+
+  if (TypeStr == "code") {
+    Field.IsCode = true;
+    return true;
+  }
+
+  if (const Record *TypeRec = Records.getDef(TypeStr)) {
+    if (TypeRec->isSubClassOf("GenericEnum")) {
+      Field.Enum = EnumMap[TypeRec];
+      Field.RecType = RecordRecTy::get(Field.Enum->Class);
       return true;
-    } else {
-      if (Record *TypeRec = Records.getDef(Type->getValue())) {
-        if (TypeRec->isSubClassOf("GenericEnum")) {
-          Field.Enum = EnumMap[TypeRec];
-          Field.RecType = RecordRecTy::get(Field.Enum->Class);
-          return true;
-        }
-      }
     }
   }
 
@@ -596,7 +599,7 @@ bool SearchableTableEmitter::parseFieldType(GenericField &Field, Init *TypeOf) {
 
 std::unique_ptr<SearchIndex> SearchableTableEmitter::parseSearchIndex(
     GenericTable &Table, const RecordVal *KeyRecVal, StringRef Name,
-    const std::vector<StringRef> &Key, bool EarlyOut, bool ReturnRange) {
+    ArrayRef<StringRef> Key, bool EarlyOut, bool ReturnRange) {
   auto Index = std::make_unique<SearchIndex>();
   Index->Name = std::string(Name);
   Index->Loc = KeyRecVal->getLoc();
@@ -626,8 +629,8 @@ std::unique_ptr<SearchIndex> SearchableTableEmitter::parseSearchIndex(
 
 void SearchableTableEmitter::collectEnumEntries(
     GenericEnum &Enum, StringRef NameField, StringRef ValueField,
-    const std::vector<Record *> &Items) {
-  for (auto *EntryRec : Items) {
+    ArrayRef<const Record *> Items) {
+  for (const Record *EntryRec : Items) {
     StringRef Name;
     if (NameField.empty())
       Name = EntryRec->getName();
@@ -655,7 +658,7 @@ void SearchableTableEmitter::collectEnumEntries(
 }
 
 void SearchableTableEmitter::collectTableEntries(
-    GenericTable &Table, const std::vector<Record *> &Items) {
+    GenericTable &Table, ArrayRef<const Record *> Items) {
   if (Items.empty())
     PrintFatalError(Table.Locs,
                     Twine("Table '") + Table.Name + "' has no entries");
@@ -686,8 +689,8 @@ void Searchable...
[truncated]

@jurahul jurahul force-pushed the const_record_searchable_table_emitter branch from 934b0bd to 3997e88 Compare September 30, 2024 13:55
@jurahul jurahul merged commit 7ac474b into llvm:main Sep 30, 2024
8 checks passed
@jurahul jurahul deleted the const_record_searchable_table_emitter branch September 30, 2024 17:08
@llvm-ci
Copy link
Collaborator

llvm-ci commented Sep 30, 2024

LLVM Buildbot has detected a new failure on builder libc-aarch64-ubuntu-fullbuild-dbg running on libc-aarch64-ubuntu while building clang,llvm,mlir at step 4 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/71/builds/7573

Here is the relevant piece of the build log for the reference
Step 4 (annotate) failure: 'python ../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py ...' (failure)
...
-- Performing Test HAVE_POSIX_REGEX -- success
-- Performing Test HAVE_STEADY_CLOCK -- success
-- Performing Test HAVE_PTHREAD_AFFINITY -- failed to compile
-- Configuring done
-- Generating done
-- Build files have been written to: /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/build
@@@BUILD_STEP build libc@@@
Running: ninja libc
[1/540] Building CXX object lib/TableGen/CMakeFiles/LLVMTableGen.dir/TableGenBackendSkeleton.cpp.o
[2/540] Building CXX object projects/libc/utils/LibcTableGenUtil/CMakeFiles/LibcTableGenUtil.dir/APIIndexer.cpp.o
FAILED: projects/libc/utils/LibcTableGenUtil/CMakeFiles/LibcTableGenUtil.dir/APIIndexer.cpp.o 
/usr/bin/clang++ -DGTEST_HAS_RTTI=0 -DLLVM_BUILD_STATIC -D_DEBUG -Iprojects/libc/utils/LibcTableGenUtil -I/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/libc/utils/LibcTableGenUtil -I/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/libc -Iinclude -I/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/llvm/include -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -g  -fno-exceptions -funwind-tables -fno-rtti -std=c++17 -MD -MT projects/libc/utils/LibcTableGenUtil/CMakeFiles/LibcTableGenUtil.dir/APIIndexer.cpp.o -MF projects/libc/utils/LibcTableGenUtil/CMakeFiles/LibcTableGenUtil.dir/APIIndexer.cpp.o.d -o projects/libc/utils/LibcTableGenUtil/CMakeFiles/LibcTableGenUtil.dir/APIIndexer.cpp.o -c /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/libc/utils/LibcTableGenUtil/APIIndexer.cpp
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/libc/utils/LibcTableGenUtil/APIIndexer.cpp:29:34: error: no viable conversion from 'ArrayRef<const llvm::Record *>' to 'ArrayRef<llvm::Record *>'
  llvm::ArrayRef<llvm::Record *> Classes = RecordType->getClasses();
                                 ^         ~~~~~~~~~~~~~~~~~~~~~~~~
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:41:40: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'ArrayRef<const llvm::Record *>' to 'const llvm::ArrayRef<llvm::Record *> &' for 1st argument
  class LLVM_GSL_POINTER [[nodiscard]] ArrayRef {
                                       ^
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:41:40: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'ArrayRef<const llvm::Record *>' to 'llvm::ArrayRef<llvm::Record *> &&' for 1st argument
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:70:18: note: candidate constructor not viable: no known conversion from 'ArrayRef<const llvm::Record *>' to 'std::nullopt_t' for 1st argument
    /*implicit*/ ArrayRef(std::nullopt_t) {}
                 ^
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:73:18: note: candidate constructor not viable: no known conversion from 'ArrayRef<const llvm::Record *>' to 'llvm::Record *const &' for 1st argument
    /*implicit*/ ArrayRef(const T &OneElt)
                 ^
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:116:28: note: candidate constructor not viable: no known conversion from 'ArrayRef<const llvm::Record *>' to 'const std::initializer_list<Record *> &' for 1st argument
    constexpr /*implicit*/ ArrayRef(const std::initializer_list<T> &Vec)
                           ^
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:90:18: note: candidate template ignored: could not match 'SmallVectorTemplateCommon' against 'ArrayRef'
    /*implicit*/ ArrayRef(const SmallVectorTemplateCommon<T, U> &Vec)
                 ^
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:96:18: note: candidate template ignored: could not match 'vector' against 'ArrayRef'
    /*implicit*/ ArrayRef(const std::vector<T, A> &Vec)
                 ^
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:101:28: note: candidate template ignored: could not match 'array' against 'ArrayRef'
    /*implicit*/ constexpr ArrayRef(const std::array<T, N> &Arr)
                           ^
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:106:28: note: candidate template ignored: could not match 'llvm::Record *const [N]' against 'ArrayRef<const llvm::Record *>'
    /*implicit*/ constexpr ArrayRef(const T (&Arr)[N]) : Data(Arr), Length(N) {}
                           ^
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:126:5: note: candidate template ignored: requirement 'std::is_convertible<const llvm::Record *const *, llvm::Record *const *>::value' was not satisfied [with U = const llvm::Record]
    ArrayRef(const ArrayRef<U *> &A,
    ^
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:135:18: note: candidate template ignored: could not match 'SmallVectorTemplateCommon' against 'ArrayRef'
    /*implicit*/ ArrayRef(
                 ^
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:144:5: note: candidate template ignored: could not match 'vector' against 'ArrayRef'
    ArrayRef(const std::vector<U *, A> &Vec,
    ^
Step 6 (build libc) failure: build libc (failure)
@@@BUILD_STEP build libc@@@
Running: ninja libc
[1/540] Building CXX object lib/TableGen/CMakeFiles/LLVMTableGen.dir/TableGenBackendSkeleton.cpp.o
[2/540] Building CXX object projects/libc/utils/LibcTableGenUtil/CMakeFiles/LibcTableGenUtil.dir/APIIndexer.cpp.o
FAILED: projects/libc/utils/LibcTableGenUtil/CMakeFiles/LibcTableGenUtil.dir/APIIndexer.cpp.o 
/usr/bin/clang++ -DGTEST_HAS_RTTI=0 -DLLVM_BUILD_STATIC -D_DEBUG -Iprojects/libc/utils/LibcTableGenUtil -I/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/libc/utils/LibcTableGenUtil -I/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/libc -Iinclude -I/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/llvm/include -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -g  -fno-exceptions -funwind-tables -fno-rtti -std=c++17 -MD -MT projects/libc/utils/LibcTableGenUtil/CMakeFiles/LibcTableGenUtil.dir/APIIndexer.cpp.o -MF projects/libc/utils/LibcTableGenUtil/CMakeFiles/LibcTableGenUtil.dir/APIIndexer.cpp.o.d -o projects/libc/utils/LibcTableGenUtil/CMakeFiles/LibcTableGenUtil.dir/APIIndexer.cpp.o -c /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/libc/utils/LibcTableGenUtil/APIIndexer.cpp
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/libc/utils/LibcTableGenUtil/APIIndexer.cpp:29:34: error: no viable conversion from 'ArrayRef<const llvm::Record *>' to 'ArrayRef<llvm::Record *>'
  llvm::ArrayRef<llvm::Record *> Classes = RecordType->getClasses();
                                 ^         ~~~~~~~~~~~~~~~~~~~~~~~~
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:41:40: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'ArrayRef<const llvm::Record *>' to 'const llvm::ArrayRef<llvm::Record *> &' for 1st argument
  class LLVM_GSL_POINTER [[nodiscard]] ArrayRef {
                                       ^
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:41:40: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'ArrayRef<const llvm::Record *>' to 'llvm::ArrayRef<llvm::Record *> &&' for 1st argument
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:70:18: note: candidate constructor not viable: no known conversion from 'ArrayRef<const llvm::Record *>' to 'std::nullopt_t' for 1st argument
    /*implicit*/ ArrayRef(std::nullopt_t) {}
                 ^
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:73:18: note: candidate constructor not viable: no known conversion from 'ArrayRef<const llvm::Record *>' to 'llvm::Record *const &' for 1st argument
    /*implicit*/ ArrayRef(const T &OneElt)
                 ^
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:116:28: note: candidate constructor not viable: no known conversion from 'ArrayRef<const llvm::Record *>' to 'const std::initializer_list<Record *> &' for 1st argument
    constexpr /*implicit*/ ArrayRef(const std::initializer_list<T> &Vec)
                           ^
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:90:18: note: candidate template ignored: could not match 'SmallVectorTemplateCommon' against 'ArrayRef'
    /*implicit*/ ArrayRef(const SmallVectorTemplateCommon<T, U> &Vec)
                 ^
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:96:18: note: candidate template ignored: could not match 'vector' against 'ArrayRef'
    /*implicit*/ ArrayRef(const std::vector<T, A> &Vec)
                 ^
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:101:28: note: candidate template ignored: could not match 'array' against 'ArrayRef'
    /*implicit*/ constexpr ArrayRef(const std::array<T, N> &Arr)
                           ^
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:106:28: note: candidate template ignored: could not match 'llvm::Record *const [N]' against 'ArrayRef<const llvm::Record *>'
    /*implicit*/ constexpr ArrayRef(const T (&Arr)[N]) : Data(Arr), Length(N) {}
                           ^
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:126:5: note: candidate template ignored: requirement 'std::is_convertible<const llvm::Record *const *, llvm::Record *const *>::value' was not satisfied [with U = const llvm::Record]
    ArrayRef(const ArrayRef<U *> &A,
    ^
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:135:18: note: candidate template ignored: could not match 'SmallVectorTemplateCommon' against 'ArrayRef'
    /*implicit*/ ArrayRef(
                 ^
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:144:5: note: candidate template ignored: could not match 'vector' against 'ArrayRef'
    ArrayRef(const std::vector<U *, A> &Vec,
    ^
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:287:5: note: candidate function
    operator std::vector<T>() const {
    ^
1 error generated.
[3/540] Building CXX object lib/TableGen/CMakeFiles/LLVMTableGen.dir/Error.cpp.o
[4/540] Building CXX object lib/TableGen/CMakeFiles/LLVMTableGen.dir/TableGenBackend.cpp.o
[5/540] Building CXX object lib/TableGen/CMakeFiles/LLVMTableGen.dir/DetailedRecordsBackend.cpp.o

@llvm-ci
Copy link
Collaborator

llvm-ci commented Sep 30, 2024

LLVM Buildbot has detected a new failure on builder libc-x86_64-debian-gcc-fullbuild-dbg running on libc-x86_64-debian-fullbuild while building clang,llvm,mlir at step 4 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/131/builds/7500

Here is the relevant piece of the build log for the reference
Step 4 (annotate) failure: 'python ../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py ...' (failure)
...
-- Performing Test HAVE_POSIX_REGEX -- success
-- Performing Test HAVE_STEADY_CLOCK -- success
-- Performing Test HAVE_PTHREAD_AFFINITY -- success
-- Configuring done
-- Generating done
-- Build files have been written to: /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/build
@@@BUILD_STEP build libc@@@
Running: ninja libc
[1/554] Building CXX object lib/TableGen/CMakeFiles/LLVMTableGen.dir/TableGenBackendSkeleton.cpp.o
[2/554] Building CXX object projects/libc/utils/LibcTableGenUtil/CMakeFiles/LibcTableGenUtil.dir/APIIndexer.cpp.o
FAILED: projects/libc/utils/LibcTableGenUtil/CMakeFiles/LibcTableGenUtil.dir/APIIndexer.cpp.o 
/usr/bin/g++ -DGTEST_HAS_RTTI=0 -DLLVM_BUILD_STATIC -D_DEBUG -I/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/build/projects/libc/utils/LibcTableGenUtil -I/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc/utils/LibcTableGenUtil -I/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc -I/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/build/include -I/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/llvm/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -fno-lifetime-dse -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -g  -fno-exceptions -funwind-tables -fno-rtti -std=c++17 -MD -MT projects/libc/utils/LibcTableGenUtil/CMakeFiles/LibcTableGenUtil.dir/APIIndexer.cpp.o -MF projects/libc/utils/LibcTableGenUtil/CMakeFiles/LibcTableGenUtil.dir/APIIndexer.cpp.o.d -o projects/libc/utils/LibcTableGenUtil/CMakeFiles/LibcTableGenUtil.dir/APIIndexer.cpp.o -c /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc/utils/LibcTableGenUtil/APIIndexer.cpp
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc/utils/LibcTableGenUtil/APIIndexer.cpp: In function ‘bool llvm_libc::isa(const llvm::Record*, const llvm::Record*)’:
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc/utils/LibcTableGenUtil/APIIndexer.cpp:29:66: error: conversion from ‘ArrayRef<const llvm::Record*>’ to non-scalar type ‘ArrayRef<llvm::Record*>’ requested
   29 |   llvm::ArrayRef<llvm::Record *> Classes = RecordType->getClasses();
      |                                            ~~~~~~~~~~~~~~~~~~~~~~^~
[3/554] Building CXX object lib/TableGen/CMakeFiles/LLVMTableGen.dir/Error.cpp.o
[4/554] Building CXX object lib/TableGen/CMakeFiles/LLVMTableGen.dir/TableGenBackend.cpp.o
[5/554] Building CXX object lib/TableGen/CMakeFiles/LLVMTableGen.dir/DetailedRecordsBackend.cpp.o
[6/554] Building CXX object lib/TableGen/CMakeFiles/LLVMTableGen.dir/Parser.cpp.o
[7/554] Building CXX object projects/libc/utils/HdrGen/CMakeFiles/libc-hdrgen.dir/PublicAPICommand.cpp.o
[8/554] Building CXX object projects/libc/utils/HdrGen/CMakeFiles/libc-hdrgen.dir/Generator.cpp.o
[9/554] Building CXX object lib/TableGen/CMakeFiles/LLVMTableGen.dir/JSONBackend.cpp.o
[10/554] Building CXX object lib/TableGen/CMakeFiles/LLVMTableGen.dir/SetTheory.cpp.o
[11/554] Building CXX object lib/TableGen/CMakeFiles/LLVMTableGen.dir/Main.cpp.o
[12/554] Building CXX object lib/TableGen/CMakeFiles/LLVMTableGen.dir/TGParser.cpp.o
[13/554] Building CXX object lib/TableGen/CMakeFiles/LLVMTableGen.dir/Record.cpp.o
ninja: build stopped: subcommand failed.
['ninja', 'libc'] exited with return code 1.
The build step threw an exception...
Traceback (most recent call last):
  File "/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/build/../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py", line 164, in step
    yield
  File "/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/build/../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py", line 121, in main
    run_command(['ninja', 'libc'])
  File "/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/build/../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py", line 179, in run_command
    util.report_run_cmd(cmd, cwd=directory)
  File "/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-zorg/zorg/buildbot/builders/annotated/util.py", line 49, in report_run_cmd
    subprocess.check_call(cmd, shell=shell, *args, **kwargs)
  File "/usr/lib/python3.11/subprocess.py", line 413, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['ninja', 'libc']' returned non-zero exit status 1.
@@@STEP_FAILURE@@@
@@@BUILD_STEP build libc-startup@@@
Running: ninja libc-startup
Step 6 (build libc) failure: build libc (failure)
@@@BUILD_STEP build libc@@@
Running: ninja libc
[1/554] Building CXX object lib/TableGen/CMakeFiles/LLVMTableGen.dir/TableGenBackendSkeleton.cpp.o
[2/554] Building CXX object projects/libc/utils/LibcTableGenUtil/CMakeFiles/LibcTableGenUtil.dir/APIIndexer.cpp.o
FAILED: projects/libc/utils/LibcTableGenUtil/CMakeFiles/LibcTableGenUtil.dir/APIIndexer.cpp.o 
/usr/bin/g++ -DGTEST_HAS_RTTI=0 -DLLVM_BUILD_STATIC -D_DEBUG -I/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/build/projects/libc/utils/LibcTableGenUtil -I/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc/utils/LibcTableGenUtil -I/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc -I/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/build/include -I/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/llvm/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -fno-lifetime-dse -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -g  -fno-exceptions -funwind-tables -fno-rtti -std=c++17 -MD -MT projects/libc/utils/LibcTableGenUtil/CMakeFiles/LibcTableGenUtil.dir/APIIndexer.cpp.o -MF projects/libc/utils/LibcTableGenUtil/CMakeFiles/LibcTableGenUtil.dir/APIIndexer.cpp.o.d -o projects/libc/utils/LibcTableGenUtil/CMakeFiles/LibcTableGenUtil.dir/APIIndexer.cpp.o -c /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc/utils/LibcTableGenUtil/APIIndexer.cpp
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc/utils/LibcTableGenUtil/APIIndexer.cpp: In function ‘bool llvm_libc::isa(const llvm::Record*, const llvm::Record*)’:
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc/utils/LibcTableGenUtil/APIIndexer.cpp:29:66: error: conversion from ‘ArrayRef<const llvm::Record*>’ to non-scalar type ‘ArrayRef<llvm::Record*>’ requested
   29 |   llvm::ArrayRef<llvm::Record *> Classes = RecordType->getClasses();
      |                                            ~~~~~~~~~~~~~~~~~~~~~~^~
[3/554] Building CXX object lib/TableGen/CMakeFiles/LLVMTableGen.dir/Error.cpp.o
[4/554] Building CXX object lib/TableGen/CMakeFiles/LLVMTableGen.dir/TableGenBackend.cpp.o
[5/554] Building CXX object lib/TableGen/CMakeFiles/LLVMTableGen.dir/DetailedRecordsBackend.cpp.o
[6/554] Building CXX object lib/TableGen/CMakeFiles/LLVMTableGen.dir/Parser.cpp.o
[7/554] Building CXX object projects/libc/utils/HdrGen/CMakeFiles/libc-hdrgen.dir/PublicAPICommand.cpp.o
[8/554] Building CXX object projects/libc/utils/HdrGen/CMakeFiles/libc-hdrgen.dir/Generator.cpp.o
[9/554] Building CXX object lib/TableGen/CMakeFiles/LLVMTableGen.dir/JSONBackend.cpp.o
[10/554] Building CXX object lib/TableGen/CMakeFiles/LLVMTableGen.dir/SetTheory.cpp.o
[11/554] Building CXX object lib/TableGen/CMakeFiles/LLVMTableGen.dir/Main.cpp.o
[12/554] Building CXX object lib/TableGen/CMakeFiles/LLVMTableGen.dir/TGParser.cpp.o
[13/554] Building CXX object lib/TableGen/CMakeFiles/LLVMTableGen.dir/Record.cpp.o
ninja: build stopped: subcommand failed.
['ninja', 'libc'] exited with return code 1.
The build step threw an exception...
Traceback (most recent call last):
  File "/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/build/../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py", line 164, in step
    yield
  File "/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/build/../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py", line 121, in main
    run_command(['ninja', 'libc'])
  File "/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/build/../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py", line 179, in run_command
    util.report_run_cmd(cmd, cwd=directory)
  File "/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-zorg/zorg/buildbot/builders/annotated/util.py", line 49, in report_run_cmd
    subprocess.check_call(cmd, shell=shell, *args, **kwargs)
  File "/usr/lib/python3.11/subprocess.py", line 413, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['ninja', 'libc']' returned non-zero exit status 1.

jurahul added a commit to jurahul/llvm-project that referenced this pull request Sep 30, 2024
Fix LibC TableGen build failure caused by llvm#110032
@jurahul
Copy link
Contributor Author

jurahul commented Sep 30, 2024

I have the fix for LIBC build failure in flight. Will commit once its approved (or when checks complete). Pre-commit builds do not seem to build this target.

jurahul added a commit that referenced this pull request Sep 30, 2024
Fix LibC TableGen build failure caused by
#110032
puja2196 pushed a commit to puja2196/LLVM-tutorial that referenced this pull request Oct 2, 2024
VitaNuo pushed a commit to VitaNuo/llvm-project that referenced this pull request Oct 2, 2024
…er (llvm#110032)

Change SeachableTableEmitter to use const RecordKeeper.
Also change RecordRecTy to use const Record pointers for its classes.

This is a part of effort to have better const correctness in TableGen
backends:


https://discourse.llvm.org/t/psa-planned-changes-to-tablegen-getallderiveddefinitions-api-potential-downstream-breakages/81089
VitaNuo pushed a commit to VitaNuo/llvm-project that referenced this pull request Oct 2, 2024
VitaNuo pushed a commit to VitaNuo/llvm-project that referenced this pull request Oct 2, 2024
…er (llvm#110032)

Change SeachableTableEmitter to use const RecordKeeper.
Also change RecordRecTy to use const Record pointers for its classes.

This is a part of effort to have better const correctness in TableGen
backends:


https://discourse.llvm.org/t/psa-planned-changes-to-tablegen-getallderiveddefinitions-api-potential-downstream-breakages/81089
VitaNuo pushed a commit to VitaNuo/llvm-project that referenced this pull request Oct 2, 2024
xgupta pushed a commit to xgupta/llvm-project that referenced this pull request Oct 4, 2024
…er (llvm#110032)

Change SeachableTableEmitter to use const RecordKeeper.
Also change RecordRecTy to use const Record pointers for its classes.

This is a part of effort to have better const correctness in TableGen
backends:


https://discourse.llvm.org/t/psa-planned-changes-to-tablegen-getallderiveddefinitions-api-potential-downstream-breakages/81089
xgupta pushed a commit to xgupta/llvm-project that referenced this pull request Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang Clang issues not falling into any other category mlir:core MLIR Core Infrastructure mlir:spirv mlir tablegen
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants