Skip to content

Conversation

@kazutakahirata
Copy link
Contributor

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Apr 19, 2025

@llvm/pr-subscribers-platform-windows
@llvm/pr-subscribers-lld-macho
@llvm/pr-subscribers-lld-elf
@llvm/pr-subscribers-lld

@llvm/pr-subscribers-lld-coff

Author: Kazu Hirata (kazutakahirata)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/136453.diff

7 Files Affected:

  • (modified) lld/COFF/MapFile.cpp (+3-4)
  • (modified) lld/ELF/AArch64ErrataFix.cpp (+6-6)
  • (modified) lld/ELF/ARMErrataFix.cpp (+5-5)
  • (modified) lld/ELF/BPSectionOrderer.cpp (+1-1)
  • (modified) lld/ELF/SyntheticSections.cpp (+1-1)
  • (modified) lld/MachO/BPSectionOrderer.cpp (+1-1)
  • (modified) lld/include/lld/Common/BPSectionOrdererBase.inc (+1-1)
diff --git a/lld/COFF/MapFile.cpp b/lld/COFF/MapFile.cpp
index eb98bb484f9f4..9b7c05b9e68b9 100644
--- a/lld/COFF/MapFile.cpp
+++ b/lld/COFF/MapFile.cpp
@@ -75,10 +75,9 @@ static void sortUniqueSymbols(std::vector<Defined *> &syms,
 
   // Remove duplicate symbol pointers
   parallelSort(v, std::less<SortEntry>());
-  auto end = std::unique(v.begin(), v.end(),
-                         [](const SortEntry &a, const SortEntry &b) {
-                           return a.first == b.first;
-                         });
+  auto end = llvm::unique(v, [](const SortEntry &a, const SortEntry &b) {
+    return a.first == b.first;
+  });
   v.erase(end, v.end());
 
   // Sort by RVA then original order
diff --git a/lld/ELF/AArch64ErrataFix.cpp b/lld/ELF/AArch64ErrataFix.cpp
index b5641e5d9ce55..e2b1cf14daa72 100644
--- a/lld/ELF/AArch64ErrataFix.cpp
+++ b/lld/ELF/AArch64ErrataFix.cpp
@@ -461,12 +461,12 @@ void AArch64Err843419Patcher::init() {
     llvm::stable_sort(mapSyms, [](const Defined *a, const Defined *b) {
       return a->value < b->value;
     });
-    mapSyms.erase(
-        std::unique(mapSyms.begin(), mapSyms.end(),
-                    [=](const Defined *a, const Defined *b) {
-                      return isCodeMapSymbol(a) == isCodeMapSymbol(b);
-                    }),
-        mapSyms.end());
+    mapSyms.erase(llvm::unique(mapSyms,
+                               [=](const Defined *a, const Defined *b) {
+                                 return isCodeMapSymbol(a) ==
+                                        isCodeMapSymbol(b);
+                               }),
+                  mapSyms.end());
     // Always start with a Code Mapping Symbol.
     if (!mapSyms.empty() && !isCodeMapSymbol(mapSyms.front()))
       mapSyms.erase(mapSyms.begin());
diff --git a/lld/ELF/ARMErrataFix.cpp b/lld/ELF/ARMErrataFix.cpp
index a7120c43e51d3..d14d28ee43a2f 100644
--- a/lld/ELF/ARMErrataFix.cpp
+++ b/lld/ELF/ARMErrataFix.cpp
@@ -354,11 +354,11 @@ void ARMErr657417Patcher::init() {
     llvm::stable_sort(mapSyms, [](const Defined *a, const Defined *b) {
       return a->value < b->value;
     });
-    mapSyms.erase(std::unique(mapSyms.begin(), mapSyms.end(),
-                              [=](const Defined *a, const Defined *b) {
-                                return (isThumbMapSymbol(a) ==
-                                        isThumbMapSymbol(b));
-                              }),
+    mapSyms.erase(llvm::unique(mapSyms,
+                               [=](const Defined *a, const Defined *b) {
+                                 return (isThumbMapSymbol(a) ==
+                                         isThumbMapSymbol(b));
+                               }),
                   mapSyms.end());
     // Always start with a Thumb Mapping Symbol
     if (!mapSyms.empty() && !isThumbMapSymbol(mapSyms.front()))
diff --git a/lld/ELF/BPSectionOrderer.cpp b/lld/ELF/BPSectionOrderer.cpp
index 4adb42ef4ff93..793176c7725a3 100644
--- a/lld/ELF/BPSectionOrderer.cpp
+++ b/lld/ELF/BPSectionOrderer.cpp
@@ -53,7 +53,7 @@ struct BPOrdererELF : lld::BPOrderer<BPOrdererELF> {
       hashes.push_back(byte);
 
     llvm::sort(hashes);
-    hashes.erase(std::unique(hashes.begin(), hashes.end()), hashes.end());
+    hashes.erase(llvm::unique(hashes), hashes.end());
   }
 
   static StringRef getSymName(const Defined &sym) { return sym.getName(); }
diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index 196ecc4fee8c8..2531227cb99b7 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -590,7 +590,7 @@ SmallVector<EhFrameSection::FdeData, 0> EhFrameSection::getFdeData() const {
   auto eq = [](const FdeData &a, const FdeData &b) {
     return a.pcRel == b.pcRel;
   };
-  ret.erase(std::unique(ret.begin(), ret.end(), eq), ret.end());
+  ret.erase(llvm::unique(ret, eq), ret.end());
 
   return ret;
 }
diff --git a/lld/MachO/BPSectionOrderer.cpp b/lld/MachO/BPSectionOrderer.cpp
index 950afd0421f06..1295d21cad8a1 100644
--- a/lld/MachO/BPSectionOrderer.cpp
+++ b/lld/MachO/BPSectionOrderer.cpp
@@ -73,7 +73,7 @@ struct BPOrdererMachO : lld::BPOrderer<BPOrdererMachO> {
     }
 
     llvm::sort(hashes);
-    hashes.erase(std::unique(hashes.begin(), hashes.end()), hashes.end());
+    hashes.erase(llvm::unique(hashes), hashes.end());
   }
 
   static llvm::StringRef getSymName(const Defined &sym) {
diff --git a/lld/include/lld/Common/BPSectionOrdererBase.inc b/lld/include/lld/Common/BPSectionOrdererBase.inc
index b19d3670d34cc..51dfb6471644a 100644
--- a/lld/include/lld/Common/BPSectionOrdererBase.inc
+++ b/lld/include/lld/Common/BPSectionOrdererBase.inc
@@ -260,7 +260,7 @@ auto BPOrderer<D>::computeOrder(
       auto &uns = startupSectionIdxUNs[sectionIdx];
       uns.append(compressionUns);
       llvm::sort(uns);
-      uns.erase(std::unique(uns.begin(), uns.end()), uns.end());
+      uns.erase(llvm::unique(uns), uns.end());
     }
   }
 

@kazutakahirata kazutakahirata merged commit f347a06 into llvm:main Apr 19, 2025
17 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_001_range_unique_lld branch April 19, 2025 20:35
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants