[lld] 5a2020d - [ELF] copyShtGroup: replace unordered_set<uint32_t> with DenseSet<uint32_t>. NFC

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 30 01:18:45 PST 2022


Author: Fangrui Song
Date: 2022-01-30T01:18:41-08:00
New Revision: 5a2020d069a69b7981917981fdca2dc35164e74d

URL: https://github.com/llvm/llvm-project/commit/5a2020d069a69b7981917981fdca2dc35164e74d
DIFF: https://github.com/llvm/llvm-project/commit/5a2020d069a69b7981917981fdca2dc35164e74d.diff

LOG: [ELF] copyShtGroup: replace unordered_set<uint32_t> with DenseSet<uint32_t>. NFC

We don't need to support the empty/tombstone key section index.

Added: 
    

Modified: 
    lld/ELF/InputSection.cpp
    lld/ELF/OutputSections.cpp

Removed: 
    


################################################################################
diff  --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp
index 570d5f561c15..f8ace8d266c5 100644
--- a/lld/ELF/InputSection.cpp
+++ b/lld/ELF/InputSection.cpp
@@ -27,7 +27,6 @@
 #include <algorithm>
 #include <mutex>
 #include <set>
-#include <unordered_set>
 #include <vector>
 
 using namespace llvm;
@@ -366,7 +365,7 @@ template <class ELFT> void InputSection::copyShtGroup(uint8_t *buf) {
   // 
diff erent in the output. We also need to handle combined or discarded
   // members.
   ArrayRef<InputSectionBase *> sections = file->getSections();
-  std::unordered_set<uint32_t> seen;
+  DenseSet<uint32_t> seen;
   for (uint32_t idx : from.slice(1)) {
     OutputSection *osec = sections[idx]->getOutputSection();
     if (osec && seen.insert(osec->sectionIndex).second)

diff  --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp
index 67758c54ab20..241b3ea3b418 100644
--- a/lld/ELF/OutputSections.cpp
+++ b/lld/ELF/OutputSections.cpp
@@ -22,7 +22,6 @@
 #include "llvm/Support/Parallel.h"
 #include "llvm/Support/SHA1.h"
 #include "llvm/Support/TimeProfiler.h"
-#include <unordered_set>
 #if LLVM_ENABLE_ZLIB
 #include <zlib.h>
 #endif
@@ -467,7 +466,7 @@ static void finalizeShtGroup(OutputSection *os,
 
   // Some group members may be combined or discarded, so we need to compute the
   // new size. The content will be rewritten in InputSection::copyShtGroup.
-  std::unordered_set<uint32_t> seen;
+  DenseSet<uint32_t> seen;
   ArrayRef<InputSectionBase *> sections = section->file->getSections();
   for (const uint32_t &idx : section->getDataAs<uint32_t>().slice(1))
     if (OutputSection *osec = sections[read32(&idx)]->getOutputSection())


        


More information about the llvm-commits mailing list