> > 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.
Indeed, I think in this case it is also possible to drop else if (tree_int_cst_equal (TYPE_SIZE (type), TYPE_SIZE (as_base))) in call.c since they will now be always different. > > 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. > > Regular derived classes would simply derive from the as-base type > (as they do now I guess). I was trying to construct testcase using this (i.e. have different access paths one using CLASSTYPE_AS_BASE and other the actual type and failed to do so. Having one would be nice. Honza > > Richard.