[lld] r249987 - ELF2: Use SmallPtrSet instead of unordered_set.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 11 10:44:22 PDT 2015
Author: ruiu
Date: Sun Oct 11 12:44:22 2015
New Revision: 249987
URL: http://llvm.org/viewvc/llvm-project?rev=249987&view=rev
Log:
ELF2: Use SmallPtrSet instead of unordered_set.
This patch addresses Rafael's review comments to r249955.
Modified:
lld/trunk/ELF/Writer.cpp
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=249987&r1=249986&r2=249987&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Sun Oct 11 12:44:22 2015
@@ -13,8 +13,8 @@
#include "SymbolTable.h"
#include "Target.h"
+#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/Support/FileOutputBuffer.h"
-#include <unordered_set>
using namespace llvm;
using namespace llvm::ELF;
@@ -473,6 +473,9 @@ template <class ELFT> void Writer<ELFT>:
++NumPhdrs;
}
}
+
+ // Reserve space needed for the program header so that the array
+ // will never be resized.
Phdrs.reserve(NumPhdrs);
// The first Phdr entry is PT_PHDR which describes the program header itself.
@@ -494,7 +497,7 @@ template <class ELFT> void Writer<ELFT>:
Elf_Phdr *FileHeader = &Phdrs.back();
phdrSet(FileHeader, PT_LOAD, PF_R, 0, getVAStart(), Target->getPageSize());
- std::unordered_set<Elf_Phdr *> Closed;
+ SmallPtrSet<Elf_Phdr *, 8> Closed;
for (OutputSectionBase<ELFT::Is64Bits> *Sec : OutputSections) {
if (Sec->getSize()) {
uintX_t Flags = toPhdrFlags(Sec->getFlags());
More information about the llvm-commits
mailing list