[lld] 4831d92 - [lld] Replace SmallSet with SmallPtrSet (NFC) (#154263)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 18 22:39:48 PDT 2025
Author: Kazu Hirata
Date: 2025-08-18T22:39:45-07:00
New Revision: 4831d92005c1332ca4b2a7d7c608071dab20f256
URL: https://github.com/llvm/llvm-project/commit/4831d92005c1332ca4b2a7d7c608071dab20f256
DIFF: https://github.com/llvm/llvm-project/commit/4831d92005c1332ca4b2a7d7c608071dab20f256.diff
LOG: [lld] Replace SmallSet with SmallPtrSet (NFC) (#154263)
This patch replaces SmallSet<T *, N> with SmallPtrSet<T *, N>. Note
that SmallSet.h "redirects" SmallSet to SmallPtrSet for pointer
element types:
template <typename PointeeType, unsigned N>
class SmallSet<PointeeType*, N> : public SmallPtrSet<PointeeType*, N>
{};
We only have 30 instances that rely on this "redirection". Since the
redirection doesn't improve readability, this patch replaces SmallSet
with SmallPtrSet for pointer element types.
I'm planning to remove the redirection eventually.
Added:
Modified:
lld/ELF/Relocations.cpp
Removed:
################################################################################
diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp
index 9cb0460a2dac0..6f55bac2ecf16 100644
--- a/lld/ELF/Relocations.cpp
+++ b/lld/ELF/Relocations.cpp
@@ -273,12 +273,12 @@ template <class ELFT> static bool isReadOnly(SharedSymbol &ss) {
// them are copied by a copy relocation, all of them need to be copied.
// Otherwise, they would refer to
diff erent places at runtime.
template <class ELFT>
-static SmallSet<SharedSymbol *, 4> getSymbolsAt(Ctx &ctx, SharedSymbol &ss) {
+static SmallPtrSet<SharedSymbol *, 4> getSymbolsAt(Ctx &ctx, SharedSymbol &ss) {
using Elf_Sym = typename ELFT::Sym;
const auto &file = cast<SharedFile>(*ss.file);
- SmallSet<SharedSymbol *, 4> ret;
+ SmallPtrSet<SharedSymbol *, 4> ret;
for (const Elf_Sym &s : file.template getGlobalELFSyms<ELFT>()) {
if (s.st_shndx == SHN_UNDEF || s.st_shndx == SHN_ABS ||
s.getType() == STT_TLS || s.st_value != ss.value)
More information about the llvm-commits
mailing list