<div dir="ltr">Are we sure we want to go this way? MachO can't even represent generalized comdats. If we want to fix the conflation of weak linkage and implicit single-member comdat groups, it might be nice to have a lighter weight more memory efficient way of representing this.<div><br></div><div>Right now every C++ inline function gets linkonce_odr, a linkage enum packed into a bitfield to say that it needs a comdat. With this change, we will copy the long C++ mangled name into a separate symbol table for not much gain.</div><div><br></div><div>Maybe we should turn linkage into a flags enum? Something like ODR, Discardable, Weak, ImplicitComdat?</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Dec 19, 2014 at 12:51 PM, Rafael EspĂ­ndola <span dir="ltr"><<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a>></span> wrote:<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">There is quiet a bit of history behind this.<br>
<br>
The llvm IR until very recently had no support for comdats. This was a<br>
problem when targeting C++ on ELF/COFF as just using weak linkage<br>
would cause quiet a bit of dead bits to remain on the executable<br>
(unless -ffunction-sections, -fdata-sections and --gc-sections were<br>
used).<br>
<br>
To fix the problem, llvm's codegen will just assume that any weak or<br>
linkonce that is not in an explicit comdat should be output in one<br>
with the same name as the global.<br>
<br>
This unfortunately breaks cases like pr19848 where a weak symbol is<br>
not expected to be part of any comdat.<br>
<br>
Now that we have explicit comdats in the IR, we can finally get both<br>
cases right.<br>
<br>
This first patch just makes clang give explicit comdats to<br>
GlobalValues where it is allowed to.<br>
<br>
A followup patch to llvm will then stop implicitly producing comdats.<br>
<br>
Cheers,<br>
Rafael<br>
<br>_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
<br></blockquote></div></div>