This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Enable TBAA on anonymous types with LTO
- From: Jan Hubicka <hubicka at ucw dot cz>
- To: Jan Hubicka <hubicka at ucw dot cz>
- Cc: Richard Biener <rguenther at suse dot de>, gcc-patches at gcc dot gnu dot org, ebotcazou at libertysurf dot fr, paul at codesourcery dot com, jason at redhat dot com
- Date: Mon, 29 Sep 2014 17:39:35 +0200
- Subject: Re: Enable TBAA on anonymous types with LTO
- Authentication-results: sourceware.org; auth=none
- References: <20140926191400 dot GB27278 at kam dot mff dot cuni dot cz> <alpine dot LSU dot 2 dot 11 dot 1409291019370 dot 20733 at zhemvz dot fhfr dot qr> <20140929153615 dot GB19673 at kam dot mff dot cuni dot cz>
> >
> > Why not just make all anonymous types their own canonical type?
> > (of course considering type variants)
>
> If C++ FE sets canonical type always to main variant, it should work.
> Is it always the case? I noticed you do this for variadic types.
> I tought there is reason why canonical types differ from main variants
> and the way canonical types are built in FE seems more complex too, than
> just setting CANONICAL=MAIN_VARIANT
> >
> > > 2) update canonical type hash so it can deal with types that already have
> > > canonical type set.
> > > I insert even anonymous types there because I am not able to get rid
> > > of cases where non-anonmous type explicitly mentions anonymous. Consider:
> > > namespace {
> > > struct B {};
> > > }
> > > struct A
> > > {
> > > void t(B);
> > > void t2();
> > > };
> > > void
> > > A::t(B)
> > > {
> > > }
> > > void
> > > A::t2()
> > > {
> > > }
> > > Here we end up having type of method T non-anonymous but it builds from B that
> > > is anonymous.
> >
> > But that makes B non-anonymous as well? How is A::t mangled? Consider
> > also the simpler case
> >
> > struct A { struct B b; };
>
> Yep, A seems to be not anonymous and mangled as A. I think it is ODR violation
> to declare such type in more than one compilation unit (and we will warn on
> it). We can make it anonymous, but I think it is C++ FE to do so.
If I update my testcase to also have struct B b as a field I get:
.type _ZN1A2t2Ev, @function
_ZN1A2t2Ev:
.LFB1:
.cfi_startproc
rep ret
.cfi_endproc
I.e. a::t is static (based on its anonymous namespace argument B) while a::t2 is normal
externally visible method for type mangled as A.