[patch] Add support for putting constructors and destructos in explicit comdats

Rafael EspĂ­ndola rafael.espindola at gmail.com
Mon Sep 1 20:03:59 PDT 2014


There are situations when clang knows that the C1 and C2 constructors
or the D2 and D2 destructors are identical. We already optimize some
of these cases, but cannot optimize it when the GlobalValue is
weak_odr.

The problem with weak_odr is that an old TU seeing the same code will
have a C1 and a C2 comdat with the corresponding symbols. We cannot
suddenly start putting the C2 symbol in the C1 comdat as we cannot
guarantee that the linker will not pick a .o with only C1 in it.

The solution implemented by GCC is to expand the ABI to have a comdat
whose name uses a C5/D5 suffix and always has both symbols. That is
what this patch implements.

We could also use C5/D5 for linkonce_odr, but it is probably better to
change one at a time.

Cheers,
Rafael
-------------- next part --------------
A non-text attachment was scrubbed...
Name: t.patch
Type: text/x-patch
Size: 23070 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140901/178bcb07/attachment.bin>


More information about the cfe-commits mailing list