[clang] [clang] Unique MultiKeywordSelector with a UniquingSet (NFC) (PR #223626)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 15 01:28:34 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
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
---
Full diff: https://github.com/llvm/llvm-project/pull/223626.diff
2 Files Affected:
- (modified) clang/include/clang/Basic/IdentifierTable.h (+3-10)
- (modified) clang/lib/Basic/IdentifierTable.cpp (+3-6)
``````````diff
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
``````````
</details>
https://github.com/llvm/llvm-project/pull/223626
More information about the cfe-commits
mailing list