Skip to content

Commit

Permalink
Switch the new COFF linker's symbol table to use a DenseMap of
Browse files Browse the repository at this point in the history
StringRefs. This uses the LLVM hashing rather than the standard library
and a closed addressed hash table rather than chaining.

This improves the Windows self-link of LLD by 4.4% (averaged over 10
runs, with well under 1% of variance on each).

There is still some room to improve here. Two things I clearly see in
the profile:

1) This is one of the biggest stress tests for the LLVM hashing code. It
   actually consumes something like 3-4% of the link time after the
   change.
2) The way that StringRef keys are handled in the DenseMap interface is
   pretty suboptimal. We pay the price of checking for empty and
   tombstone keys when we could only possibly be looking for a normal
   key. But fixing this requires invasive API changes.

So there is still some headroom here.

Differential Revision: http://reviews.llvm.org/D10684

llvm-svn: 240871
  • Loading branch information
chandlerc committed Jun 27, 2015
1 parent 3294670 commit 2eb15ff
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lld/COFF/SymbolTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
#define LLD_COFF_SYMBOL_TABLE_H

#include "InputFiles.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseMapInfo.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/raw_ostream.h"
#include <unordered_map>

namespace llvm {
struct LTOCodeGenerator;
Expand Down Expand Up @@ -90,7 +91,7 @@ class SymbolTable {
std::error_code addMemberFile(Lazy *Body);
ErrorOr<ObjectFile *> createLTOObject(llvm::LTOCodeGenerator *CG);

std::unordered_map<StringRef, Symbol *> Symtab;
llvm::DenseMap<StringRef, Symbol *> Symtab;
std::vector<std::unique_ptr<InputFile>> Files;
size_t FileIdx = 0;
std::vector<ArchiveFile *> ArchiveFiles;
Expand Down

0 comments on commit 2eb15ff

Please sign in to comment.