Handle versioned symbols efficiently.
authorRui Ueyama <ruiu@google.com>
Sun, 17 Jul 2016 17:23:17 +0000 (17:23 +0000)
committerRui Ueyama <ruiu@google.com>
Sun, 17 Jul 2016 17:23:17 +0000 (17:23 +0000)
commit663b8c2769c349094b2b083d10edc489671b8209
tree8d0d9fd77b874ae9279447153dc64f7481effcf7
parentd1e941ae851552d3e95270141e92ad89561e0545
Handle versioned symbols efficiently.

Versions can be assigned to symbols in two different ways.
One is the usual version scripts, and the other is special
symbol suffix '@'. If a symbol contains '@', the string after
that is considered to specify a version name.

Previously, we look for '@' for all symbols.

Anything that works on every symbol can be expensive because
the linker has to handle a lot of symbols. The search for '@'
was not an exception.

In this patch, I made two optimizations.

The first optimization is to handle '@' only when at least one
version is defined. If no versions are defined, no versions can
be assigned to any symbols, so it's waste of time to search for '@'.

The second optimization is to scan only suffixes of symbol names
instead of entire symbol names. Symbol names can be very long, but
symbol versions are usually short, so scanning entire symbol names
is waste of time, too.

There are some error cases which we no longer be able to detect
with this patch. I don't think it's a major drawback because they
are minor errors. Speed is more important.

This change improves LLD with debug info self-link time from
6.6993 seconds to 6.3426 seconds (or -5.3%).

Differential Revision: https://reviews.llvm.org/D22433

llvm-svn: 275711
lld/ELF/Config.h
lld/ELF/Driver.cpp
lld/ELF/SymbolTable.cpp
lld/ELF/SymbolTable.h
lld/ELF/Symbols.cpp
lld/ELF/Symbols.h
lld/test/ELF/verdef-defaultver.s
lld/test/ELF/verdef-executable.s [deleted file]