https://github.com/kazutakahirata created 
https://github.com/llvm/llvm-project/pull/223626

This patch migrates MultiKeywordSelector in SelectorTable from
llvm::FoldingSet to llvm::UniquingSet.

MultiKeywordSelector keys on an ArrayRef<const IdentifierInfo *>.
Switching to UniquingSet allows us to look up multi-keyword selectors
with a typed key, eliminating FoldingSetNodeID serialization at lookup
sites and removing MultiKeywordSelector::Profile.

Assisted-by: Antigravity


>From b5cd6c09b01b4ded01a123d629d6b01fdcf85789 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <[email protected]>
Date: Sun, 13 Sep 2026 16:46:49 -0700
Subject: [PATCH] [clang] Unique MultiKeywordSelector with a UniquingSet (NFC)

This patch migrates MultiKeywordSelector in SelectorTable from
llvm::FoldingSet to llvm::UniquingSet.

MultiKeywordSelector keys on an ArrayRef<const IdentifierInfo *>.
Switching to UniquingSet allows us to look up multi-keyword selectors
with a typed key, eliminating FoldingSetNodeID serialization at lookup
sites and removing MultiKeywordSelector::Profile.

Assisted-by: Antigravity
---
 clang/include/clang/Basic/IdentifierTable.h | 13 +++----------
 clang/lib/Basic/IdentifierTable.cpp         |  9 +++------
 2 files changed, 6 insertions(+), 16 deletions(-)

diff --git a/clang/include/clang/Basic/IdentifierTable.h 
b/clang/include/clang/Basic/IdentifierTable.h
index 79a2aecebf55b..ac1acb7ddac61 100644
--- a/clang/include/clang/Basic/IdentifierTable.h
+++ b/clang/include/clang/Basic/IdentifierTable.h
@@ -943,7 +943,7 @@ class alignas(IdentifierInfoAlignment) DeclarationNameExtra 
{
 } // namespace detail
 
 /// One of these variable length records is kept for each
-/// selector containing more than one keyword. We use a folding set
+/// selector containing more than one keyword. We use UniquingSet
 /// to unique aggregate names (keyword selectors in ObjC parlance). Access to
 /// this class is provided strictly through Selector.
 class alignas(IdentifierInfoAlignment) MultiKeywordSelector
@@ -984,15 +984,8 @@ class alignas(IdentifierInfoAlignment) MultiKeywordSelector
     return keyword_begin()[i];
   }
 
-  static void Profile(llvm::FoldingSetNodeID &ID, keyword_iterator ArgTys,
-                      unsigned NumArgs) {
-    ID.AddInteger(NumArgs);
-    for (unsigned i = 0; i != NumArgs; ++i)
-      ID.AddPointer(ArgTys[i]);
-  }
-
-  void Profile(llvm::FoldingSetNodeID &ID) {
-    Profile(ID, keyword_begin(), getNumArgs());
+  ArrayRef<const IdentifierInfo *> getKey() const {
+    return {keyword_begin(), getNumArgs()};
   }
 };
 
diff --git a/clang/lib/Basic/IdentifierTable.cpp 
b/clang/lib/Basic/IdentifierTable.cpp
index aa349fcc384ce..55cd0f7677517 100644
--- a/clang/lib/Basic/IdentifierTable.cpp
+++ b/clang/lib/Basic/IdentifierTable.cpp
@@ -705,7 +705,7 @@ ObjCStringFormatFamily 
Selector::getStringFormatFamilyImpl(Selector sel) {
 namespace {
 
 struct SelectorTableImpl {
-  llvm::FoldingSet<MultiKeywordSelector> Table;
+  llvm::UniquingSet<MultiKeywordSelector> Table;
   llvm::BumpPtrAllocator Allocator;
 };
 
@@ -750,12 +750,9 @@ Selector SelectorTable::getSelector(unsigned nKeys,
 
   SelectorTableImpl &SelTabImpl = getSelectorTableImpl(Impl);
 
-  // Unique selector, to guarantee there is one per name.
-  llvm::FoldingSetNodeID ID;
-  MultiKeywordSelector::Profile(ID, IIV, nKeys);
-
   llvm::FoldingSetInsertToken InsertToken;
-  if (MultiKeywordSelector *SI = SelTabImpl.Table.lookup(ID, InsertToken))
+  if (MultiKeywordSelector *SI =
+          SelTabImpl.Table.lookup(ArrayRef(IIV, nKeys), InsertToken))
     return Selector(SI);
 
   // MultiKeywordSelector objects are not allocated with new because they have 
a

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to