]> granicus.if.org Git - llvm/commit
[asan] Put ctor/dtor in comdat.
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>
Thu, 27 Apr 2017 20:27:23 +0000 (20:27 +0000)
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>
Thu, 27 Apr 2017 20:27:23 +0000 (20:27 +0000)
commitcd2999ea454aa0315b96c3689de9fbafa18572ed
tree2abcb697d33934ea8eca23fa58d518ffc964777c
parentb0c82b846cb5949a38f2aa9c7469f5087ae192d2
[asan] Put ctor/dtor in comdat.

When possible, put ASan ctor/dtor in comdat.

The only reason not to is global registration, which can be
TU-specific. This is not the case when there are no instrumented
globals. This is also limited to ELF targets, because MachO does
not have comdat, and COFF linkers may GC comdat constructors.

The benefit of this is a lot less __asan_init() calls: one per DSO
instead of one per TU. It's also necessary for the upcoming
gc-sections-for-globals change on Linux, where multiple references to
section start symbols trigger quadratic behaviour in gold linker.

This is a second re-land of r298756. This time with a flag to disable
the whole thing to avoid a bug in the gold linker:
  https://sourceware.org/bugzilla/show_bug.cgi?id=19002

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301586 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Instrumentation/AddressSanitizer.cpp
test/Instrumentation/AddressSanitizer/instrument_global.ll
test/Instrumentation/AddressSanitizer/no-globals.ll [new file with mode: 0644]