This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C++ patch] Reduce vtable alignment
- From: Jan Hubicka <hubicka at ucw dot cz>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: Richard Biener <richard dot guenther at gmail dot com>, Jan Hubicka <hubicka at ucw dot cz>, GCC Patches <gcc-patches at gcc dot gnu dot org>, Jason Merrill <jason at redhat dot com>
- Date: Mon, 19 May 2014 16:56:57 +0200
- Subject: Re: [C++ patch] Reduce vtable alignment
- Authentication-results: sourceware.org; auth=none
- References: <20140516180442 dot GI20755 at kam dot mff dot cuni dot cz> <20140516191242 dot GA10833 at kam dot mff dot cuni dot cz> <CAFiYyc3S1TpPa8rM-yZn=e9ykkxj_T_kGNn5PzLQG=G-k4ZsAg at mail dot gmail dot com> <20140519091043 dot GH10386 at tucnak dot redhat dot com>
> > Hmm, but if the optimizers or the target can rely on DATA_ABI_ALIGNMENT
> > then we can't really lower it. Because we can make the vtable escape
> > to another unit that sees it as just an array of pointers?
>
> Sure, they can rely on DATA_ABI_ALIGNMENT (if that macro is defined), but
> anything beyond that (such as what DATA_ALIGNMENT returns) is optimization
> only. So, Honza's patch looks good for me.
Yep, DATA_ALIGNMENT is computed when type is finalized, so I think this should
be safe.
>
> > So this looks unsafe to me. (same may apply to the idea of
> > having TARGET_VTABLE_ENTRY_ALIGN at all, if that possibly
> > conflicts with ABI alignment requirements present otherwise).
>
> Right now the intersection of targets overriding TARGET_VTABLE_ENTRY_ALIGN and
> targets defining DATA_ABI_ALIGNMENT is empty. In any case, even in that
> case one should (if DATA_ABI_ALIGNMENT is defined) apply DATA_ABI_ALIGNMENT
> (on top of TARGET_VTABLE_ENTRY_ALIGN and/or TYPE_ALIGN, dunno how those two
> exactly mix together) and not DATA_ALIGNMENT. But this patch is about
> tinfo, not vtable.
There are two patches, one is for RTTI and other is for vtables. Vtables are
fully compiler controlled structures, as such I think we do not need to align
them as usual arrays. C++ ABI does not really speak about alignment of these,
but I believe it is safe to stop aligning them, since all we do is random
accesses at given offset of the symbol - nothing where we can use the
alignment.
We can bump it down to DATA_ALIGNMENT boundary like I do for RTTI, but it
would still waste several percent of the data segment. (Clang indeed aligns
to 16 byte boundary here)
Honza