This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH: No vcall offsets for primary construction virtual tables
- From: Mark Mitchell <mark at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 27 Nov 2006 18:22:39 -0800
- Subject: C++ PATCH: No vcall offsets for primary construction virtual tables
- Reply-to: mark at codesourcery dot com
The C++ front end was generating vcall offsets for primary
construction (aka A-in-A-in-B) virtual tables. There is no reason to
generate vcall offsets in such a virtual table, even if A is virtual,
since, in the circumstances when this virtual table is used, A is a
complete object. This virtual table is just like the A-in-A virtual
table, except that the offsets of various subobjects are different;
there is no need for extra entries.
This is not an ABI change, since nothing ever looked at those offsets,
and since construction virtual tables are only referenced from a VTT,
and since the VTT and the construction virtual tables go in the same
COMDAT group.
Tested on x86_64-unknown-linux-gnu, applied to mainline.
--
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713
2006-11-27 Mark Mitchell <mark@codesourcery.com>
* class.c (build_vcall_offset_vtbl_entries): Do not add vcall
entries for a primary construction virtual table.
Index: gcc/cp/class.c
===================================================================
--- gcc/cp/class.c (revision 119231)
+++ gcc/cp/class.c (working copy)
@@ -7449,7 +7449,14 @@ build_vcall_offset_vtbl_entries (tree bi
/* We only need these entries if this base is a virtual base. We
compute the indices -- but do not add to the vtable -- when
building the main vtable for a class. */
- if (BINFO_VIRTUAL_P (binfo) || binfo == TYPE_BINFO (vid->derived))
+ if (binfo == TYPE_BINFO (vid->derived)
+ || (BINFO_VIRTUAL_P (binfo)
+ /* If BINFO is RTTI_BINFO, then (since BINFO does not
+ correspond to VID->DERIVED), we are building a primary
+ construction virtual table. Since this is a primary
+ virtual table, we do not need the vcall offsets for
+ BINFO. */
+ && binfo != vid->rtti_binfo))
{
/* We need a vcall offset for each of the virtual functions in this
vtable. For example: