[PATCH] Reorder fields in struct cgraph_edge et al

Martin Jambor mjambor@suse.cz
Wed Dec 2 12:02:00 GMT 2009


Hi,

On Tue, Dec 01, 2009 at 12:33:38PM +0100, Richard Guenther wrote:
> On Tue, 1 Dec 2009, Martin Jambor wrote:
> > On Tue, Dec 01, 2009 at 12:04:58PM +0100, Richard Guenther wrote:
> > > On Tue, 1 Dec 2009, Martin Jambor wrote:
> > > > On Tue, Dec 01, 2009 at 10:46:33AM +0100, Richard Guenther wrote:
> > > > > 
> > > > > you now have introduced 32bit padding here ...
> > > > > 
> > > > 
> > > > No, even on i386 gcov_type is 64 bit.  I have just double checked.
> > > > I have committed the patch as it was per Honza's approval.
> > > 
> > > But what's the point moving it first, even before the next pointer?
> > > The next pointer is accessed during traversing, possibly quite more
> > > frequent than count.
> > > 
> > 
> > Well, after I saw how misaligned everything was (and so how little we,
> > including myself, sometimes care about this when we add stuff), I
> > thought that reordering the fields according to their size was the
> > safest way of preventing someone from inadvertently reintroducing the
> > padding.  Even more so because nobody seems to really remember how big
> > gcov_type actually is (I also had to ask Honza, probably not for the
> > first time).
> > 
> > Having said that, putting it after next_callee with a comment about
> > this is probably also rather safe (as opposed to anything lower than
> > that).  I can do that if you want.
> 
> Well, I don't care too much - it's just another thing I do when
> re-arranging fields, put pointer chains first.
> 

No problem, the following has bootstrapped and tested on an
x86_64-linux overnight.  We probably wouldn't even be causeing much
fuss by committing it.

Martin


2009-12-02  Martin Jambor  <mjambor@suse.cz>

	* cgraph.h (struct cgraph_edge): Move count after next_callee.

Index: icln/gcc/cgraph.h
===================================================================
--- icln.orig/gcc/cgraph.h
+++ icln/gcc/cgraph.h
@@ -310,14 +310,15 @@ typedef enum {
 } cgraph_inline_failed_t;
 
 struct GTY((chain_next ("%h.next_caller"), chain_prev ("%h.prev_caller"))) cgraph_edge {
-  /* Expected number of executions: calculated in profile.c.  */
-  gcov_type count;
   struct cgraph_node *caller;
   struct cgraph_node *callee;
   struct cgraph_edge *prev_caller;
   struct cgraph_edge *next_caller;
   struct cgraph_edge *prev_callee;
   struct cgraph_edge *next_callee;
+  /* Expected number of executions: calculated in profile.c.  This field should
+     be aligned to 64 bits on all targets.  */
+  gcov_type count;
   gimple call_stmt;
   PTR GTY ((skip (""))) aux;
   /* When equal to CIF_OK, inline this call.  Otherwise, points to the



More information about the Gcc-patches mailing list