On 6/20/19 11:49 AM, Richard Biener wrote:
On June 20, 2019 4:06:58 PM GMT+02:00, Nathan Sidwell <nat...@acm.org> wrote:
On 6/20/19 9:37 AM, Richard Biener wrote:
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 think you might end up with unordered fields? virtual empty bases
don't appear in the as-base variant, and I think they could appear in
the middle of the as-instance variant. that might or might not be a
problem?
Certainly interesting, but if they are empty it might not be an issue if they
are never referred to (address taken?)
their address could be taken -- the layout rules are such that no two
empty objects of the same type can have the same offset. This is
important to determine if two references are to the same instance or
not. It can't be dereferenced though. and I guess emitting a static
initializer wouldn't have anything to put there -- though varasm might
barf on non-monotonic offsets regardless.
I don't know how common virtual empty bases are in practice.
(non-virtual ones would be in the as-base instance, and not have this
problem)
nathan
--
Nathan Sidwell