[asan] Put ctor/dtor in comdat.
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>
Sat, 25 Mar 2017 01:01:11 +0000 (01:01 +0000)
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>
Sat, 25 Mar 2017 01:01:11 +0000 (01:01 +0000)
commit71bb8f1ad09fb33439b0a1c861084e8a6833f75c
treeceb6afd53a6019521379f374120b3163852c0225
parent86e630b8572a68a79f44644d7b2eccddf6bb68a7
[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.

llvm-svn: 298756
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
llvm/test/Instrumentation/AddressSanitizer/instrument_global.ll
llvm/test/Instrumentation/AddressSanitizer/no-globals.ll [new file with mode: 0644]