Skip to content

[TableGen] Change all type pointers to const #110602

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

Merged
merged 1 commit into from
Oct 1, 2024

Conversation

jurahul
Copy link
Contributor

@jurahul jurahul commented Sep 30, 2024

@jurahul jurahul marked this pull request as ready for review October 1, 2024 03:24
@jurahul jurahul requested a review from arsenm October 1, 2024 03:24
@llvmbot
Copy link
Member

llvmbot commented Oct 1, 2024

@llvm/pr-subscribers-tablegen

Author: Rahul Joshi (jurahul)

Changes

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 59.65 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/110602.diff

6 Files Affected:

  • (modified) llvm/include/llvm/TableGen/Record.h (+80-78)
  • (modified) llvm/lib/TableGen/Record.cpp (+67-67)
  • (modified) llvm/lib/TableGen/TGParser.cpp (+56-59)
  • (modified) llvm/lib/TableGen/TGParser.h (+13-13)
  • (modified) llvm/utils/TableGen/Common/CodeGenRegisters.cpp (+1-1)
  • (modified) llvm/utils/TableGen/SearchableTableEmitter.cpp (+2-2)
diff --git a/llvm/include/llvm/TableGen/Record.h b/llvm/include/llvm/TableGen/Record.h
index 6c07391893c88d..f39a2ee9f1d9bb 100644
--- a/llvm/include/llvm/TableGen/Record.h
+++ b/llvm/include/llvm/TableGen/Record.h
@@ -73,8 +73,9 @@ class RecTy {
   RecTyKind Kind;
   /// The RecordKeeper that uniqued this Type.
   RecordKeeper &RK;
-  /// ListRecTy of the list that has elements of this type.
-  ListRecTy *ListTy = nullptr;
+  /// ListRecTy of the list that has elements of this type. Its a cache that
+  /// is populated on demand.
+  mutable const ListRecTy *ListTy = nullptr;
 
 public:
   RecTy(RecTyKind K, RecordKeeper &RK) : Kind(K), RK(RK) {}
@@ -98,7 +99,7 @@ class RecTy {
   virtual bool typeIsA(const RecTy *RHS) const;
 
   /// Returns the type representing list<thistype>.
-  ListRecTy *getListTy();
+  const ListRecTy *getListTy() const;
 };
 
 inline raw_ostream &operator<<(raw_ostream &OS, const RecTy &Ty) {
@@ -117,7 +118,7 @@ class BitRecTy : public RecTy {
     return RT->getRecTyKind() == BitRecTyKind;
   }
 
-  static BitRecTy *get(RecordKeeper &RK);
+  static const BitRecTy *get(RecordKeeper &RK);
 
   std::string getAsString() const override { return "bit"; }
 
@@ -136,7 +137,7 @@ class BitsRecTy : public RecTy {
     return RT->getRecTyKind() == BitsRecTyKind;
   }
 
-  static BitsRecTy *get(RecordKeeper &RK, unsigned Sz);
+  static const BitsRecTy *get(RecordKeeper &RK, unsigned Sz);
 
   unsigned getNumBits() const { return Size; }
 
@@ -156,7 +157,7 @@ class IntRecTy : public RecTy {
     return RT->getRecTyKind() == IntRecTyKind;
   }
 
-  static IntRecTy *get(RecordKeeper &RK);
+  static const IntRecTy *get(RecordKeeper &RK);
 
   std::string getAsString() const override { return "int"; }
 
@@ -174,7 +175,7 @@ class StringRecTy : public RecTy {
     return RT->getRecTyKind() == StringRecTyKind;
   }
 
-  static StringRecTy *get(RecordKeeper &RK);
+  static const StringRecTy *get(RecordKeeper &RK);
 
   std::string getAsString() const override;
 
@@ -184,11 +185,11 @@ class StringRecTy : public RecTy {
 /// 'list<Ty>' - Represent a list of element values, all of which must be of
 /// the specified type. The type is stored in ElementTy.
 class ListRecTy : public RecTy {
-  friend ListRecTy *RecTy::getListTy();
+  friend const ListRecTy *RecTy::getListTy() const;
 
-  RecTy *ElementTy;
+  const RecTy *ElementTy;
 
-  explicit ListRecTy(RecTy *T)
+  explicit ListRecTy(const RecTy *T)
       : RecTy(ListRecTyKind, T->getRecordKeeper()), ElementTy(T) {}
 
 public:
@@ -196,8 +197,8 @@ class ListRecTy : public RecTy {
     return RT->getRecTyKind() == ListRecTyKind;
   }
 
-  static ListRecTy *get(RecTy *T) { return T->getListTy(); }
-  RecTy *getElementType() const { return ElementTy; }
+  static const ListRecTy *get(const RecTy *T) { return T->getListTy(); }
+  const RecTy *getElementType() const { return ElementTy; }
 
   std::string getAsString() const override;
 
@@ -217,7 +218,7 @@ class DagRecTy : public RecTy {
     return RT->getRecTyKind() == DagRecTyKind;
   }
 
-  static DagRecTy *get(RecordKeeper &RK);
+  static const DagRecTy *get(RecordKeeper &RK);
 
   std::string getAsString() const override;
 };
@@ -249,8 +250,9 @@ class RecordRecTy final : public RecTy,
   }
 
   /// Get the record type with the given non-redundant list of superclasses.
-  static RecordRecTy *get(RecordKeeper &RK, ArrayRef<const Record *> Classes);
-  static RecordRecTy *get(const Record *Class);
+  static const RecordRecTy *get(RecordKeeper &RK,
+                                ArrayRef<const Record *> Classes);
+  static const RecordRecTy *get(const Record *Class);
 
   void Profile(FoldingSetNodeID &ID) const;
 
@@ -273,7 +275,7 @@ class RecordRecTy final : public RecTy,
 
 /// Find a common type that T1 and T2 convert to.
 /// Return 0 if no such type exists.
-RecTy *resolveTypes(RecTy *T1, RecTy *T2);
+const RecTy *resolveTypes(const RecTy *T1, const RecTy *T2);
 
 //===----------------------------------------------------------------------===//
 //  Initializer Classes
@@ -371,12 +373,12 @@ class Init {
   /// If this value is convertible to type \p Ty, return a value whose
   /// type is \p Ty, generating a !cast operation if required.
   /// Otherwise, return null.
-  virtual Init *getCastTo(RecTy *Ty) const = 0;
+  virtual Init *getCastTo(const RecTy *Ty) const = 0;
 
   /// Convert to a value whose type is \p Ty, or return null if this
   /// is not possible. This can happen if the value's type is convertible
   /// to \p Ty, but there are unresolved references.
-  virtual Init *convertInitializerTo(RecTy *Ty) const = 0;
+  virtual Init *convertInitializerTo(const RecTy *Ty) const = 0;
 
   /// This function is used to implement the bit range
   /// selection operator. Given a value, it selects the specified bits,
@@ -389,7 +391,7 @@ class Init {
   /// This function is used to implement the FieldInit class.
   /// Implementors of this method should return the type of the named
   /// field if they are of type record.
-  virtual RecTy *getFieldType(StringInit *FieldName) const {
+  virtual const RecTy *getFieldType(StringInit *FieldName) const {
     return nullptr;
   }
 
@@ -412,10 +414,10 @@ inline raw_ostream &operator<<(raw_ostream &OS, const Init &I) {
 /// This is the common superclass of types that have a specific,
 /// explicit type, stored in ValueTy.
 class TypedInit : public Init {
-  RecTy *ValueTy;
+  const RecTy *ValueTy;
 
 protected:
-  explicit TypedInit(InitKind K, RecTy *T, uint8_t Opc = 0)
+  explicit TypedInit(InitKind K, const RecTy *T, uint8_t Opc = 0)
       : Init(K, Opc), ValueTy(T) {}
 
 public:
@@ -428,20 +430,20 @@ class TypedInit : public Init {
   }
 
   /// Get the type of the Init as a RecTy.
-  RecTy *getType() const { return ValueTy; }
+  const RecTy *getType() const { return ValueTy; }
 
   /// Get the record keeper that initialized this Init.
   RecordKeeper &getRecordKeeper() const { return ValueTy->getRecordKeeper(); }
 
-  Init *getCastTo(RecTy *Ty) const override;
-  Init *convertInitializerTo(RecTy *Ty) const override;
+  Init *getCastTo(const RecTy *Ty) const override;
+  Init *convertInitializerTo(const RecTy *Ty) const override;
 
   Init *convertInitializerBitRange(ArrayRef<unsigned> Bits) const override;
 
   /// This method is used to implement the FieldInit class.
   /// Implementors of this method should return the type of the named field if
   /// they are of type record.
-  RecTy *getFieldType(StringInit *FieldName) const override;
+  const RecTy *getFieldType(StringInit *FieldName) const override;
 };
 
 /// '?' - Represents an uninitialized value.
@@ -467,8 +469,8 @@ class UnsetInit : public Init {
   /// Get the record keeper that initialized this Init.
   RecordKeeper &getRecordKeeper() const { return RK; }
 
-  Init *getCastTo(RecTy *Ty) const override;
-  Init *convertInitializerTo(RecTy *Ty) const override;
+  Init *getCastTo(const RecTy *Ty) const override;
+  Init *convertInitializerTo(const RecTy *Ty) const override;
 
   Init *getBit(unsigned Bit) const override {
     return const_cast<UnsetInit*>(this);
@@ -539,8 +541,10 @@ class ArgumentInit : public Init, public FoldingSetNode {
   bool isComplete() const override { return false; }
   bool isConcrete() const override { return false; }
   Init *getBit(unsigned Bit) const override { return Value->getBit(Bit); }
-  Init *getCastTo(RecTy *Ty) const override { return Value->getCastTo(Ty); }
-  Init *convertInitializerTo(RecTy *Ty) const override {
+  Init *getCastTo(const RecTy *Ty) const override {
+    return Value->getCastTo(Ty);
+  }
+  Init *convertInitializerTo(const RecTy *Ty) const override {
     return Value->convertInitializerTo(Ty);
   }
 };
@@ -551,7 +555,8 @@ class BitInit final : public TypedInit {
 
   bool Value;
 
-  explicit BitInit(bool V, RecTy *T) : TypedInit(IK_BitInit, T), Value(V) {}
+  explicit BitInit(bool V, const RecTy *T)
+      : TypedInit(IK_BitInit, T), Value(V) {}
 
 public:
   BitInit(const BitInit &) = delete;
@@ -565,7 +570,7 @@ class BitInit final : public TypedInit {
 
   bool getValue() const { return Value; }
 
-  Init *convertInitializerTo(RecTy *Ty) const override;
+  Init *convertInitializerTo(const RecTy *Ty) const override;
 
   Init *getBit(unsigned Bit) const override {
     assert(Bit < 1 && "Bit index out of range!");
@@ -602,7 +607,7 @@ class BitsInit final : public TypedInit, public FoldingSetNode,
 
   unsigned getNumBits() const { return NumBits; }
 
-  Init *convertInitializerTo(RecTy *Ty) const override;
+  Init *convertInitializerTo(const RecTy *Ty) const override;
   Init *convertInitializerBitRange(ArrayRef<unsigned> Bits) const override;
   std::optional<int64_t> convertInitializerToInt() const;
 
@@ -648,7 +653,7 @@ class IntInit : public TypedInit {
 
   int64_t getValue() const { return Value; }
 
-  Init *convertInitializerTo(RecTy *Ty) const override;
+  Init *convertInitializerTo(const RecTy *Ty) const override;
   Init *convertInitializerBitRange(ArrayRef<unsigned> Bits) const override;
 
   bool isConcrete() const override { return true; }
@@ -723,7 +728,7 @@ class StringInit : public TypedInit {
   StringFormat getFormat() const { return Format; }
   bool hasCodeFormat() const { return Format == SF_Code; }
 
-  Init *convertInitializerTo(RecTy *Ty) const override;
+  Init *convertInitializerTo(const RecTy *Ty) const override;
 
   bool isConcrete() const override { return true; }
 
@@ -753,7 +758,7 @@ class ListInit final : public TypedInit, public FoldingSetNode,
   using const_iterator = Init *const *;
 
 private:
-  explicit ListInit(unsigned N, RecTy *EltTy)
+  explicit ListInit(unsigned N, const RecTy *EltTy)
       : TypedInit(IK_ListInit, ListRecTy::get(EltTy)), NumValues(N) {}
 
 public:
@@ -766,7 +771,7 @@ class ListInit final : public TypedInit, public FoldingSetNode,
   static bool classof(const Init *I) {
     return I->getKind() == IK_ListInit;
   }
-  static ListInit *get(ArrayRef<Init *> Range, RecTy *EltTy);
+  static ListInit *get(ArrayRef<Init *> Range, const RecTy *EltTy);
 
   void Profile(FoldingSetNodeID &ID) const;
 
@@ -774,13 +779,13 @@ class ListInit final : public TypedInit, public FoldingSetNode,
     assert(i < NumValues && "List element index out of range!");
     return getTrailingObjects<Init *>()[i];
   }
-  RecTy *getElementType() const {
+  const RecTy *getElementType() const {
     return cast<ListRecTy>(getType())->getElementType();
   }
 
   Record *getElementAsRecord(unsigned i) const;
 
-  Init *convertInitializerTo(RecTy *Ty) const override;
+  Init *convertInitializerTo(const RecTy *Ty) const override;
 
   /// This method is used by classes that refer to other
   /// variables which may not be defined at the time they expression is formed.
@@ -812,8 +817,8 @@ class ListInit final : public TypedInit, public FoldingSetNode,
 ///
 class OpInit : public TypedInit {
 protected:
-  explicit OpInit(InitKind K, RecTy *Type, uint8_t Opc)
-    : TypedInit(K, Type, Opc) {}
+  explicit OpInit(InitKind K, const RecTy *Type, uint8_t Opc)
+      : TypedInit(K, Type, Opc) {}
 
 public:
   OpInit(const OpInit &) = delete;
@@ -855,8 +860,8 @@ class UnOpInit : public OpInit, public FoldingSetNode {
 private:
   Init *LHS;
 
-  UnOpInit(UnaryOp opc, Init *lhs, RecTy *Type)
-    : OpInit(IK_UnOpInit, Type, opc), LHS(lhs) {}
+  UnOpInit(UnaryOp opc, Init *lhs, const RecTy *Type)
+      : OpInit(IK_UnOpInit, Type, opc), LHS(lhs) {}
 
 public:
   UnOpInit(const UnOpInit &) = delete;
@@ -866,7 +871,7 @@ class UnOpInit : public OpInit, public FoldingSetNode {
     return I->getKind() == IK_UnOpInit;
   }
 
-  static UnOpInit *get(UnaryOp opc, Init *lhs, RecTy *Type);
+  static UnOpInit *get(UnaryOp opc, Init *lhs, const RecTy *Type);
 
   void Profile(FoldingSetNodeID &ID) const;
 
@@ -933,8 +938,8 @@ class BinOpInit : public OpInit, public FoldingSetNode {
 private:
   Init *LHS, *RHS;
 
-  BinOpInit(BinaryOp opc, Init *lhs, Init *rhs, RecTy *Type) :
-      OpInit(IK_BinOpInit, Type, opc), LHS(lhs), RHS(rhs) {}
+  BinOpInit(BinaryOp opc, Init *lhs, Init *rhs, const RecTy *Type)
+      : OpInit(IK_BinOpInit, Type, opc), LHS(lhs), RHS(rhs) {}
 
 public:
   BinOpInit(const BinOpInit &) = delete;
@@ -944,8 +949,7 @@ class BinOpInit : public OpInit, public FoldingSetNode {
     return I->getKind() == IK_BinOpInit;
   }
 
-  static BinOpInit *get(BinaryOp opc, Init *lhs, Init *rhs,
-                        RecTy *Type);
+  static BinOpInit *get(BinaryOp opc, Init *lhs, Init *rhs, const RecTy *Type);
   static Init *getStrConcat(Init *lhs, Init *rhs);
   static Init *getListConcat(TypedInit *lhs, Init *rhs);
 
@@ -1001,9 +1005,8 @@ class TernOpInit : public OpInit, public FoldingSetNode {
 private:
   Init *LHS, *MHS, *RHS;
 
-  TernOpInit(TernaryOp opc, Init *lhs, Init *mhs, Init *rhs,
-             RecTy *Type) :
-      OpInit(IK_TernOpInit, Type, opc), LHS(lhs), MHS(mhs), RHS(rhs) {}
+  TernOpInit(TernaryOp opc, Init *lhs, Init *mhs, Init *rhs, const RecTy *Type)
+      : OpInit(IK_TernOpInit, Type, opc), LHS(lhs), MHS(mhs), RHS(rhs) {}
 
 public:
   TernOpInit(const TernOpInit &) = delete;
@@ -1013,9 +1016,8 @@ class TernOpInit : public OpInit, public FoldingSetNode {
     return I->getKind() == IK_TernOpInit;
   }
 
-  static TernOpInit *get(TernaryOp opc, Init *lhs,
-                         Init *mhs, Init *rhs,
-                         RecTy *Type);
+  static TernOpInit *get(TernaryOp opc, Init *lhs, Init *mhs, Init *rhs,
+                         const RecTy *Type);
 
   void Profile(FoldingSetNodeID &ID) const;
 
@@ -1061,11 +1063,10 @@ class TernOpInit : public OpInit, public FoldingSetNode {
 class CondOpInit final : public TypedInit, public FoldingSetNode,
                       public TrailingObjects<CondOpInit, Init *> {
   unsigned NumConds;
-  RecTy *ValType;
+  const RecTy *ValType;
 
-  CondOpInit(unsigned NC, RecTy *Type)
-    : TypedInit(IK_CondOpInit, Type),
-      NumConds(NC), ValType(Type) {}
+  CondOpInit(unsigned NC, const RecTy *Type)
+      : TypedInit(IK_CondOpInit, Type), NumConds(NC), ValType(Type) {}
 
   size_t numTrailingObjects(OverloadToken<Init *>) const {
     return 2*NumConds;
@@ -1079,12 +1080,12 @@ class CondOpInit final : public TypedInit, public FoldingSetNode,
     return I->getKind() == IK_CondOpInit;
   }
 
-  static CondOpInit *get(ArrayRef<Init*> C, ArrayRef<Init*> V,
-                        RecTy *Type);
+  static CondOpInit *get(ArrayRef<Init *> C, ArrayRef<Init *> V,
+                         const RecTy *Type);
 
   void Profile(FoldingSetNodeID &ID) const;
 
-  RecTy *getValType() const { return ValType; }
+  const RecTy *getValType() const { return ValType; }
 
   unsigned getNumConds() const { return NumConds; }
 
@@ -1141,7 +1142,8 @@ class FoldOpInit : public TypedInit, public FoldingSetNode {
   Init *B;
   Init *Expr;
 
-  FoldOpInit(Init *Start, Init *List, Init *A, Init *B, Init *Expr, RecTy *Type)
+  FoldOpInit(Init *Start, Init *List, Init *A, Init *B, Init *Expr,
+             const RecTy *Type)
       : TypedInit(IK_FoldOpInit, Type), Start(Start), List(List), A(A), B(B),
         Expr(Expr) {}
 
@@ -1152,7 +1154,7 @@ class FoldOpInit : public TypedInit, public FoldingSetNode {
   static bool classof(const Init *I) { return I->getKind() == IK_FoldOpInit; }
 
   static FoldOpInit *get(Init *Start, Init *List, Init *A, Init *B, Init *Expr,
-                         RecTy *Type);
+                         const RecTy *Type);
 
   void Profile(FoldingSetNodeID &ID) const;
 
@@ -1172,10 +1174,10 @@ class FoldOpInit : public TypedInit, public FoldingSetNode {
 /// !isa<type>(expr) - Dynamically determine the type of an expression.
 class IsAOpInit : public TypedInit, public FoldingSetNode {
 private:
-  RecTy *CheckType;
+  const RecTy *CheckType;
   Init *Expr;
 
-  IsAOpInit(RecTy *CheckType, Init *Expr)
+  IsAOpInit(const RecTy *CheckType, Init *Expr)
       : TypedInit(IK_IsAOpInit, IntRecTy::get(CheckType->getRecordKeeper())),
         CheckType(CheckType), Expr(Expr) {}
 
@@ -1185,7 +1187,7 @@ class IsAOpInit : public TypedInit, public FoldingSetNode {
 
   static bool classof(const Init *I) { return I->getKind() == IK_IsAOpInit; }
 
-  static IsAOpInit *get(RecTy *CheckType, Init *Expr);
+  static IsAOpInit *get(const RecTy *CheckType, Init *Expr);
 
   void Profile(FoldingSetNodeID &ID) const;
 
@@ -1206,10 +1208,10 @@ class IsAOpInit : public TypedInit, public FoldingSetNode {
 /// `expr` exists.
 class ExistsOpInit : public TypedInit, public FoldingSetNode {
 private:
-  RecTy *CheckType;
+  const RecTy *CheckType;
   Init *Expr;
 
-  ExistsOpInit(RecTy *CheckType, Init *Expr)
+  ExistsOpInit(const RecTy *CheckType, Init *Expr)
       : TypedInit(IK_ExistsOpInit, IntRecTy::get(CheckType->getRecordKeeper())),
         CheckType(CheckType), Expr(Expr) {}
 
@@ -1219,7 +1221,7 @@ class ExistsOpInit : public TypedInit, public FoldingSetNode {
 
   static bool classof(const Init *I) { return I->getKind() == IK_ExistsOpInit; }
 
-  static ExistsOpInit *get(RecTy *CheckType, Init *Expr);
+  static ExistsOpInit *get(const RecTy *CheckType, Init *Expr);
 
   void Profile(FoldingSetNodeID &ID) const;
 
@@ -1240,7 +1242,7 @@ class ExistsOpInit : public TypedInit, public FoldingSetNode {
 class VarInit : public TypedInit {
   Init *VarName;
 
-  explicit VarInit(Init *VN, RecTy *T)
+  explicit VarInit(Init *VN, const RecTy *T)
       : TypedInit(IK_VarInit, T), VarName(VN) {}
 
 public:
@@ -1251,8 +1253,8 @@ class VarInit : public TypedInit {
     return I->getKind() == IK_VarInit;
   }
 
-  static VarInit *get(StringRef VN, RecTy *T);
-  static VarInit *get(Init *VN, RecTy *T);
+  static VarInit *get(StringRef VN, const RecTy *T);
+  static VarInit *get(Init *VN, const RecTy *T);
 
   StringRef getName() const;
   Init *getNameInit() const { return VarName; }
@@ -1326,11 +1328,11 @@ class DefInit : public TypedInit {
     return I->getKind() == IK_DefInit;
   }
 
-  Init *convertInitializerTo(RecTy *Ty) const override;
+  Init *convertInitializerTo(const RecTy *Ty) const override;
 
   Record *getDef() const { return Def; }
 
-  RecTy *getFieldType(StringInit *FieldName) const override;
+  const RecTy *getFieldType(StringInit *FieldName) const override;
 
   bool isConcrete() const override { return true; }
   std::string getAsString() const override;
@@ -1552,7 +1554,7 @@ class RecordVal {
 private:
   Init *Name;
   SMLoc Loc; // Source location of definition of name.
-  PointerIntPair<RecTy *, 2, FieldKind> TyAndKind;
+  PointerIntPair<const RecTy *, 2, FieldKind> TyAndKind;
   Init *Value;
   bool IsUsed = false;
 
@@ -1560,8 +1562,8 @@ class RecordVal {
   SmallVector<SMRange> ReferenceLocs;
 
 public:
-  RecordVal(Init *N, RecTy *T, FieldKind K);
-  RecordVal(Init *N, SMLoc Loc, RecTy *T, FieldKind K);
+  RecordVal(Init *N, const RecTy *T, FieldKind K);
+  RecordVal(Init *N, SMLoc Loc, const RecTy *T, FieldKind K);
 
   /// Get the record keeper used to unique this value.
   RecordKeeper &getRecordKeeper() const { return Name->getRecordKeeper(); }
@@ -1591,7 +1593,7 @@ class RecordVal {
   }
 
   /// Get the type of the field value as a RecTy.
-  RecTy *getType() const { return TyAndKind.getPointer(); }
+  const RecTy *getType() const { return TyAndKind.getPointer(); }
 
   /// Get the type of the field for printing purposes.
   std::string getPrintType() const;
@@ -1736,7 +1738,7 @@ class Record {
   void updateClassLoc(SMLoc Loc);
 
   // Make the type that this record should have based on its superclasses.
-  RecordRecTy *getType() const;
+  const RecordRecTy *getType() const;
 
   /// get the corresponding DefInit.
   DefInit *getDefInit() const;
diff --git a/llvm/lib/TableGen/Record.cpp b/llvm/lib/TableGen/Record.cpp
index 2973ef40642554..0a5d384239d5ed 100644
--- a/llvm/lib/TableGen/Record.cpp
+++ b/llvm/lib/TableGen/Record.cpp
@@ -82,7 +82,7 @@ struct RecordKeeperImpl {
   FoldingSet<FoldOpInit> TheFoldOpInitPool;
   FoldingSet<IsAOpInit> TheIsAOpInitPool;
   FoldingSet<ExistsOpInit> TheExistsOpInitPool;
-  DenseMap<std::pair<RecTy *, Init *>, VarInit *> TheVarInitPool;
+  DenseMap<std::pair<const RecTy *, Init *>, VarInit *> TheVarInitPool;
   DenseMap<std::pair<TypedInit *, unsigned>, VarBitInit *> TheVarBitInitPool;
   FoldingSet<VarDefInit> TheVarDefInitPool;
   DenseMap<std::pair<Init *, StringInit *>, FieldInit *> TheFieldInitPool;
@@ -133,7 +133,7 @@ void detail::RecordKeeperImpl::dumpAllocationStats(raw_o...
[truncated]

@jurahul jurahul merged commit 9d95e26 into llvm:main Oct 1, 2024
12 checks passed
@jurahul jurahul deleted the const_record_type_pointers branch October 1, 2024 13:54
Sterling-Augustine pushed a commit to Sterling-Augustine/llvm-project that referenced this pull request Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants