This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ patch] Reduce vtable alignment
- From: Jan Hubicka <hubicka at ucw dot cz>
- To: gcc-patches at gcc dot gnu dot org, jason at redhat dot com
- Date: Fri, 16 May 2014 20:04:42 +0200
- Subject: [C++ patch] Reduce vtable alignment
- Authentication-results: sourceware.org; auth=none
Hi,
compiling:
struct A
{
virtual void foo(void) {};
virtual void foo2(void) {};
virtual void foo3(void) {};
virtual void foo4(void) {};
virtual void foo5(void) {};
} a;
give 32 byte alignment to the virtual table on i386, because we bump up
alignments of arrays to size of vector operations. This is wasteful, since
virutal tables are never really accessed this way.
I am testing the following patch, OK if it passes?
The patch also removes apparently 20 years old hack for SPARC.
Honza
* class.c (build_vtable): Force alignment of virtual tables
to be pointer size only to save space.
Index: class.c
===================================================================
--- class.c (revision 210521)
+++ class.c (working copy)
@@ -768,11 +768,8 @@ build_vtable (tree class_type, tree name
TREE_READONLY (decl) = 1;
DECL_VIRTUAL_P (decl) = 1;
DECL_ALIGN (decl) = TARGET_VTABLE_ENTRY_ALIGN;
+ DECL_USER_ALIGN (decl) = true;
DECL_VTABLE_OR_VTT_P (decl) = 1;
- /* At one time the vtable info was grabbed 2 words at a time. This
- fails on sparc unless you have 8-byte alignment. (tiemann) */
- DECL_ALIGN (decl) = MAX (TYPE_ALIGN (double_type_node),
- DECL_ALIGN (decl));
set_linkage_according_to_type (class_type, decl);
/* The vtable has not been defined -- yet. */
DECL_EXTERNAL (decl) = 1;