Revert "Simplify a variable type by using StringRef instead of CachedHashStringRef."

This reverts commit r303787.

It caused a slowdown in fast links. That is, links with no debug info
or optimizations.

llvm-svn: 303925
This commit is contained in:
Rafael Espindola 2017-05-25 21:53:02 +00:00
parent d4039f7283
commit 1c2baad6dd
4 changed files with 20 additions and 14 deletions

View File

@ -192,7 +192,7 @@ ArrayRef<SymbolBody *> elf::ObjectFile<ELFT>::getSymbols() {
} }
template <class ELFT> template <class ELFT>
void elf::ObjectFile<ELFT>::parse(DenseSet<StringRef> &ComdatGroups) { void elf::ObjectFile<ELFT>::parse(DenseSet<CachedHashStringRef> &ComdatGroups) {
// Read section and symbol tables. // Read section and symbol tables.
initializeSections(ComdatGroups); initializeSections(ComdatGroups);
initializeSymbols(); initializeSymbols();
@ -280,7 +280,7 @@ bool elf::ObjectFile<ELFT>::shouldMerge(const Elf_Shdr &Sec) {
template <class ELFT> template <class ELFT>
void elf::ObjectFile<ELFT>::initializeSections( void elf::ObjectFile<ELFT>::initializeSections(
DenseSet<StringRef> &ComdatGroups) { DenseSet<CachedHashStringRef> &ComdatGroups) {
ArrayRef<Elf_Shdr> ObjSections = ArrayRef<Elf_Shdr> ObjSections =
check(this->getObj().sections(), toString(this)); check(this->getObj().sections(), toString(this));
const ELFFile<ELFT> &Obj = this->getObj(); const ELFFile<ELFT> &Obj = this->getObj();
@ -305,7 +305,10 @@ void elf::ObjectFile<ELFT>::initializeSections(
switch (Sec.sh_type) { switch (Sec.sh_type) {
case SHT_GROUP: case SHT_GROUP:
this->Sections[I] = &InputSection::Discarded; this->Sections[I] = &InputSection::Discarded;
if (ComdatGroups.insert(getShtGroupSignature(ObjSections, Sec)).second) if (ComdatGroups
.insert(
CachedHashStringRef(getShtGroupSignature(ObjSections, Sec)))
.second)
continue; continue;
for (uint32_t SecIndex : getShtGroupEntries(Sec)) { for (uint32_t SecIndex : getShtGroupEntries(Sec)) {
if (SecIndex >= Size) if (SecIndex >= Size)
@ -873,10 +876,10 @@ static Symbol *createBitcodeSymbol(const std::vector<bool> &KeptComdats,
} }
template <class ELFT> template <class ELFT>
void BitcodeFile::parse(DenseSet<StringRef> &ComdatGroups) { void BitcodeFile::parse(DenseSet<CachedHashStringRef> &ComdatGroups) {
std::vector<bool> KeptComdats; std::vector<bool> KeptComdats;
for (StringRef S : Obj->getComdatTable()) for (StringRef S : Obj->getComdatTable())
KeptComdats.push_back(ComdatGroups.insert(StringRef(S)).second); KeptComdats.push_back(ComdatGroups.insert(CachedHashStringRef(S)).second);
for (const lto::InputFile::Symbol &ObjSym : Obj->symbols()) for (const lto::InputFile::Symbol &ObjSym : Obj->symbols())
Symbols.push_back(createBitcodeSymbol<ELFT>(KeptComdats, ObjSym, this)); Symbols.push_back(createBitcodeSymbol<ELFT>(KeptComdats, ObjSym, this));
@ -1045,10 +1048,10 @@ template void ArchiveFile::parse<ELF32BE>();
template void ArchiveFile::parse<ELF64LE>(); template void ArchiveFile::parse<ELF64LE>();
template void ArchiveFile::parse<ELF64BE>(); template void ArchiveFile::parse<ELF64BE>();
template void BitcodeFile::parse<ELF32LE>(DenseSet<StringRef> &); template void BitcodeFile::parse<ELF32LE>(DenseSet<CachedHashStringRef> &);
template void BitcodeFile::parse<ELF32BE>(DenseSet<StringRef> &); template void BitcodeFile::parse<ELF32BE>(DenseSet<CachedHashStringRef> &);
template void BitcodeFile::parse<ELF64LE>(DenseSet<StringRef> &); template void BitcodeFile::parse<ELF64LE>(DenseSet<CachedHashStringRef> &);
template void BitcodeFile::parse<ELF64BE>(DenseSet<StringRef> &); template void BitcodeFile::parse<ELF64BE>(DenseSet<CachedHashStringRef> &);
template void LazyObjectFile::parse<ELF32LE>(); template void LazyObjectFile::parse<ELF32LE>();
template void LazyObjectFile::parse<ELF32BE>(); template void LazyObjectFile::parse<ELF32BE>();

View File

@ -17,6 +17,7 @@
#include "lld/Core/LLVM.h" #include "lld/Core/LLVM.h"
#include "lld/Core/Reproduce.h" #include "lld/Core/Reproduce.h"
#include "llvm/ADT/CachedHashString.h"
#include "llvm/ADT/DenseSet.h" #include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/STLExtras.h"
#include "llvm/IR/Comdat.h" #include "llvm/IR/Comdat.h"
@ -156,7 +157,7 @@ public:
ArrayRef<SymbolBody *> getLocalSymbols(); ArrayRef<SymbolBody *> getLocalSymbols();
ObjectFile(MemoryBufferRef M, StringRef ArchiveName); ObjectFile(MemoryBufferRef M, StringRef ArchiveName);
void parse(llvm::DenseSet<StringRef> &ComdatGroups); void parse(llvm::DenseSet<llvm::CachedHashStringRef> &ComdatGroups);
InputSectionBase *getSection(const Elf_Sym &Sym) const; InputSectionBase *getSection(const Elf_Sym &Sym) const;
@ -188,7 +189,8 @@ public:
StringRef SourceFile; StringRef SourceFile;
private: private:
void initializeSections(llvm::DenseSet<StringRef> &ComdatGroups); void
initializeSections(llvm::DenseSet<llvm::CachedHashStringRef> &ComdatGroups);
void initializeSymbols(); void initializeSymbols();
void initializeDwarfLine(); void initializeDwarfLine();
InputSectionBase *getRelocTarget(const Elf_Shdr &Sec); InputSectionBase *getRelocTarget(const Elf_Shdr &Sec);
@ -263,7 +265,8 @@ public:
BitcodeFile(MemoryBufferRef M, StringRef ArchiveName, BitcodeFile(MemoryBufferRef M, StringRef ArchiveName,
uint64_t OffsetInArchive); uint64_t OffsetInArchive);
static bool classof(const InputFile *F) { return F->kind() == BitcodeKind; } static bool classof(const InputFile *F) { return F->kind() == BitcodeKind; }
template <class ELFT> void parse(llvm::DenseSet<StringRef> &ComdatGroups); template <class ELFT>
void parse(llvm::DenseSet<llvm::CachedHashStringRef> &ComdatGroups);
ArrayRef<Symbol *> getSymbols() { return Symbols; } ArrayRef<Symbol *> getSymbols() { return Symbols; }
std::unique_ptr<llvm::lto::InputFile> Obj; std::unique_ptr<llvm::lto::InputFile> Obj;

View File

@ -122,7 +122,7 @@ template <class ELFT> void SymbolTable<ELFT>::addCombinedLTOObject() {
for (InputFile *File : LTO->compile()) { for (InputFile *File : LTO->compile()) {
ObjectFile<ELFT> *Obj = cast<ObjectFile<ELFT>>(File); ObjectFile<ELFT> *Obj = cast<ObjectFile<ELFT>>(File);
DenseSet<StringRef> DummyGroups; DenseSet<CachedHashStringRef> DummyGroups;
Obj->parse(DummyGroups); Obj->parse(DummyGroups);
ObjectFiles.push_back(Obj); ObjectFiles.push_back(Obj);
} }

View File

@ -117,7 +117,7 @@ private:
// Comdat groups define "link once" sections. If two comdat groups have the // Comdat groups define "link once" sections. If two comdat groups have the
// same name, only one of them is linked, and the other is ignored. This set // same name, only one of them is linked, and the other is ignored. This set
// is used to uniquify them. // is used to uniquify them.
llvm::DenseSet<StringRef> ComdatGroups; llvm::DenseSet<llvm::CachedHashStringRef> ComdatGroups;
std::vector<ObjectFile<ELFT> *> ObjectFiles; std::vector<ObjectFile<ELFT> *> ObjectFiles;
std::vector<SharedFile<ELFT> *> SharedFiles; std::vector<SharedFile<ELFT> *> SharedFiles;