forked from OSchip/llvm-project
[ELF] Remove .strtab deduplication
D118577: the 0.1~1.1% .strtab size reduction does not justify the 3~6% link time increase. Just remove it even for -O2. release/14.x has D118577 and the release note mentioned that this may be removed. Fix https://github.com/ClangBuiltLinux/linux/issues/1578 caused by D118577 (empty string not in stringMap).
This commit is contained in:
parent
e3b9bb5a18
commit
c12d49c4e2
|
@ -1230,6 +1230,7 @@ StringTableSection::StringTableSection(StringRef name, bool dynamic)
|
|||
dynamic(dynamic) {
|
||||
// ELF string tables start with a NUL byte.
|
||||
strings.push_back("");
|
||||
stringMap.try_emplace(CachedHashStringRef(""), 0);
|
||||
size = 1;
|
||||
}
|
||||
|
||||
|
@ -2156,9 +2157,7 @@ void SymbolTableBaseSection::sortSymTabSymbols() {
|
|||
void SymbolTableBaseSection::addSymbol(Symbol *b) {
|
||||
// Adding a local symbol to a .dynsym is a bug.
|
||||
assert(this->type != SHT_DYNSYM || !b->isLocal());
|
||||
|
||||
bool hashIt = b->isLocal() && config->optimize >= 2;
|
||||
symbols.push_back({b, strTabSec.addString(b->getName(), hashIt)});
|
||||
symbols.push_back({b, strTabSec.addString(b->getName(), false)});
|
||||
}
|
||||
|
||||
size_t SymbolTableBaseSection::getSymbolIndex(Symbol *sym) {
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
# REQUIRES: x86
|
||||
# RUN: split-file %s %t
|
||||
# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/a.s -o %t/a.o
|
||||
# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/b.s -o %t/b.o
|
||||
|
||||
## By default local symbol names are not deduplicated.
|
||||
# RUN: ld.lld %t/a.o %t/b.o -o %t/a
|
||||
# RUN: llvm-readelf -p .strtab %t/a | FileCheck %s --check-prefix=NODEDUP
|
||||
|
||||
# NODEDUP: [ 1] local
|
||||
# NODEDUP-NEXT: [ 7] local
|
||||
# NODEDUP-NEXT: [ d] foo
|
||||
# NODEDUP-EMPTY:
|
||||
|
||||
## -O2 deduplicates local symbol names.
|
||||
# RUN: ld.lld -O2 %t/a.o %t/b.o -o %t/a
|
||||
# RUN: llvm-readelf -p .strtab %t/a | FileCheck %s --check-prefix=DEDUP
|
||||
|
||||
# DEDUP: [ 1] local
|
||||
# DEDUP-NEXT: [ 7] foo
|
||||
# DEDUP-EMPTY:
|
||||
|
||||
#--- a.s
|
||||
.global foo
|
||||
foo:
|
||||
local:
|
||||
ret
|
||||
|
||||
#--- b.s
|
||||
.weak foo
|
||||
foo:
|
||||
local:
|
||||
ret
|
|
@ -0,0 +1,36 @@
|
|||
# REQUIRES: x86
|
||||
# RUN: split-file %s %t
|
||||
# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/a.s -o %t/a.o
|
||||
# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/b.s -o %t/b.o
|
||||
|
||||
## Non-empty local symbol names are not deduplicated. This helps parallel
|
||||
## .symtab write. We used to perform deduplication at -O2.
|
||||
# RUN: ld.lld %t/a.o %t/b.o -o %t/a
|
||||
# RUN: llvm-readelf -p .strtab %t/a | FileCheck %s --check-prefix=NODEDUP
|
||||
# RUN: ld.lld -r -O2 %t/a.o %t/b.o -o %t/a.ro
|
||||
# RUN: llvm-readelf -p .strtab %t/a.ro | FileCheck %s --check-prefix=NODEDUP
|
||||
|
||||
# NODEDUP: [ 1] local
|
||||
# NODEDUP-NEXT: [ 7] local
|
||||
# NODEDUP-NEXT: [ d] foo
|
||||
# NODEDUP-EMPTY:
|
||||
|
||||
# RUN: llvm-readelf -s %t/a.ro | FileCheck %s --check-prefix=SYMTAB
|
||||
|
||||
# SYMTAB: 0: {{0+}} 0 NOTYPE LOCAL DEFAULT UND
|
||||
# SYMTAB-NEXT: NOTYPE LOCAL DEFAULT [[#]] local
|
||||
# SYMTAB-NEXT: SECTION LOCAL DEFAULT [[#]] .text
|
||||
# SYMTAB-NEXT: NOTYPE LOCAL DEFAULT [[#]] local
|
||||
# SYMTAB-NEXT: NOTYPE GLOBAL DEFAULT [[#]] foo
|
||||
|
||||
#--- a.s
|
||||
.global foo
|
||||
foo:
|
||||
local:
|
||||
ret
|
||||
|
||||
#--- b.s
|
||||
.weak foo
|
||||
foo:
|
||||
local:
|
||||
ret
|
Loading…
Reference in New Issue