Use ODR for canonical types construction in LTO
Richard Biener
rguenther@suse.de
Mon Jun 24 11:28:00 GMT 2019
On Mon, 24 Jun 2019, Jan Hubicka wrote:
> > > This simple (untested) patch doesn't avoid creating the unnecessary
> > > as-base types, but it should avoid using them in a way that causes
> > > them to be streamed, and should let them be discarded by GC.
> > > Thoughts?
> >
> > Looks better than Honzas patch fixing a single place.
>
> I wonder if we can go ahead with Jason's patch to handle the common
> case.
I hope so - Jason?
> >
> > I've spent some thoughts on this and I wonder whether we can
> > re-implement classtype-as-base with fake inheritance (which would
> > also solve the TBAA alias set issue in a natural way). That is,
> > we'd lay out structs as-base and make instances of it use a
> >
> > class as-instance { as-base b; X pad1; Y pad2; };
> >
> > with either explicit padding fields or with implicit ones
> > (I didn't check how we trick stor-layout to not pad the as-base
> > type to its natural alignment...).
> >
> > I realize that this impacts all code building component-refs ontop
> > of as-instance typed objects so this might rule out this approach
> > completely - but maybe that's reasonably well abstracted into common
> > code so only few places need adjustments.
>
> Modulo the empty virtual bases which I have no understnading to I
> suppose this should work.
>
> One issue is that we will need to introduce view_convert_exprs at some
> times.
>
> As
>
> class a var;
> class b:a {} *bptr;
>
> var.foo;
>
> Expanding this as var.as_base_a.foo would make access path oracle to
> disambiguate it from bptr->as_base_b->as_base_a.foo which is wrong with
> gimple memory moel where we allow placement new replacing var by
> instance of b.
Ick. IIRC the as-base types were necessary only for
copying and clobber operations that may not touch the possibly
re-used tail-padding. The question is whether we cannot invent
a better mechanism to do this -- IIRC we used memmove for the
former case at some point (that's arguably worse, also for TBAA).
There's WITH_SIZE_EXPR which we only handle rudimentary in the
middle-end though.
> So the way to generate it would be to first view convert expr *bptr to
> as_base_b and continue from that. This would probably force us to not
> give up at view converts in the access path disambiguation :)
Yeah. No good solution either :/
Richard.
More information about the Gcc-patches
mailing list