public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [C++ patch] Reduce vtable alignment
@ 2014-05-16 18:04 Jan Hubicka
  2014-05-16 19:12 ` Jan Hubicka
  0 siblings, 1 reply; 7+ messages in thread
From: Jan Hubicka @ 2014-05-16 18:04 UTC (permalink / raw)
  To: gcc-patches, jason

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;

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-05-23 21:52 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-16 18:04 [C++ patch] Reduce vtable alignment Jan Hubicka
2014-05-16 19:12 ` Jan Hubicka
2014-05-19  8:52   ` Richard Biener
2014-05-19  9:10     ` Jakub Jelinek
2014-05-19 14:57       ` Jan Hubicka
2014-05-23 17:30     ` Jan Hubicka
2014-05-23 21:52       ` Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).