On Thu, Dec 18, 2014 at 5:56 PM, Richard Smith <rich...@metafoo.co.uk> wrote: > > On Thu, Dec 18, 2014 at 5:52 PM, David Majnemer <david.majne...@gmail.com> > wrote: >> >> On Thu, Dec 18, 2014 at 5:46 PM, Richard Smith <rich...@metafoo.co.uk> >> wrote: >>> >>> On Thu, Dec 18, 2014 at 2:30 PM, David Majnemer < >>> david.majne...@gmail.com> wrote: >>>> >>>> On Wednesday, December 17, 2014, Richard Smith <rich...@metafoo.co.uk> >>>> wrote: >>>> >>>>> On Wed, Dec 17, 2014 at 3:52 PM, Rafael Espíndola < >>>>> rafael.espind...@gmail.com> wrote: >>>>>> >>>>>> > Based on talking to David, we think the frontend should be >>>>>> responsible for >>>>>> > picking whether things are ODR or not, and then LLVM optimizations >>>>>> can >>>>>> > continue to be mostly ignorant of comdats. For example, the D5 >>>>>> destructor >>>>>> > comdat group functions should all be inlinable. >>>>>> >>>>>> +1 :-) >>>>>> >>>>> >>>>> I think that makes a lot of sense. Does this imply that globals within >>>>> a comdat would need to have some kind of weak linkage? >>>>> >>>> >>>> The only non-weak linkage we allow in COMDATs is external. The closest >>>> analog is weak_odr but it has subtly different semantics wrt duplicate >>>> symbol definitions. >>>> >>>> I'll try to dig up a concrete example as soon as I can get to my laptop. >>>> >>> >>> I think Rafael's right here: external symbols in a comdat are meaningful >>> (and presumably they mean that you can't have that symbol defined in any >>> other object file you link in, so you either get your definition or no >>> definition), and I can imagine (rare) cases when they might be what you >>> want. (And if not, don't do that...) >>> >> >> I think it means something different from what you are suggesting. >> STB_WEAK is orthogonal to COMDAT-ness. Clang when targeting MSVC uses >> COMDATs with external linkage to mean: >> - This symbol is in some COMDAT group >> - It is not weak, don't replace my symbol with some non-weak definition. >> - This symbol cannot be discarded. >> >> I don't think there is another combination of linkage and comdat-ness >> which gets the same effects. >> > > ... in that case, all our interprocedural optimizations *do* need to know > about comdats, and being in a comdat needs to make an external symbol > effectively weak for optimization purposes (you can't propagate information > out of it, because it might be replaced by a different definition). This > violates Reid's desire that optimizations can be mostly ignorant of comdats. >
An external symbol in a COMDAT should be identical in all COMDAT groups that it could be in. If you can't find issue with it, I'll add it to the langref.
_______________________________________________ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits