diff mbox

[c++] rewrite vtable initialization construction to use VECs

Message ID 20100615201557.GL27105@codesourcery.com
State New
Headers show

Commit Message

Nathan Froyd June 15, 2010, 8:15 p.m. UTC
On Tue, Jun 15, 2010 at 01:10:38PM -0700, Steve Ellcey wrote:
> On Tue, 2010-06-15 at 10:59 -0700, Nathan Froyd wrote:
> > Would you try the below patch (against mainline, not on top of my
> > previous patch), please?  I think that should resolve the problems
> > you're seeing, assuming I didn't botch my arithmetic.
> 
> Nope, this isn't working.

Gah.  I did indeed botch my arithmetic.  New patch below.

> Should
> 	VEC_replace (constructor_elt, vid.inits, new_position, e);
> be
> 	VEC_replace (constructor_elt, *inits, new_position, e);
> 
> It doesn't look like this changed in your patch, but it differs from
> other VEC_replace calls.

No.  We've just built virtual function initializers in vid.inits; *inits
contains the initializers for the entire class hierarchy.  vid.inits
needs some tweaking before we stuff its contents into *inits.

Thanks for bearing with me.

-Nathan

Comments

Steve Ellcey June 16, 2010, 12:43 a.m. UTC | #1
On Tue, 2010-06-15 at 13:15 -0700, Nathan Froyd wrote:

> Index: class.c
> ===================================================================
> --- class.c	(revision 160473)
> +++ class.c	(working copy)
> @@ -7618,14 +7618,15 @@ build_vtbl_initializer (tree binfo,
>  	   ix--)
>  	{
>  	  int j;
> -	  int new_position = TARGET_VTABLE_DATA_ENTRY_DISTANCE * ix;
> +	  int new_position = (TARGET_VTABLE_DATA_ENTRY_DISTANCE * ix
> +			      + (TARGET_VTABLE_DATA_ENTRY_DISTANCE - 1));
>  
>  	  VEC_replace (constructor_elt, vid.inits, new_position, e);
>  
>  	  for (j = 1; j < TARGET_VTABLE_DATA_ENTRY_DISTANCE; ++j)
>  	    {
> -	      constructor_elt *f = VEC_index (constructor_elt, *inits,
> -					      new_position + j);
> +	      constructor_elt *f = VEC_index (constructor_elt, vid.inits,
> +					      new_position - j);
>  	      f->index = NULL_TREE;
>  	      f->value = build1 (NOP_EXPR, vtable_entry_type,
>  				 null_pointer_node);
> 

This latest patch is looking good.  The bootstrap worked and testing is
looking good too.  I haven't finished a full test run yet but I am not
seeing any regressions so far.

Steve Ellcey
sje@cup.hp.com
Steve Ellcey June 16, 2010, 5:21 p.m. UTC | #2
Nathan,

I finished a full bootstrap and test of the last patch you sent me and
it looks good on IA64 HP-UX.

Steve Ellcey
sje@cup.hp.com
diff mbox

Patch

Index: class.c
===================================================================
--- class.c	(revision 160473)
+++ class.c	(working copy)
@@ -7618,14 +7618,15 @@  build_vtbl_initializer (tree binfo,
 	   ix--)
 	{
 	  int j;
-	  int new_position = TARGET_VTABLE_DATA_ENTRY_DISTANCE * ix;
+	  int new_position = (TARGET_VTABLE_DATA_ENTRY_DISTANCE * ix
+			      + (TARGET_VTABLE_DATA_ENTRY_DISTANCE - 1));
 
 	  VEC_replace (constructor_elt, vid.inits, new_position, e);
 
 	  for (j = 1; j < TARGET_VTABLE_DATA_ENTRY_DISTANCE; ++j)
 	    {
-	      constructor_elt *f = VEC_index (constructor_elt, *inits,
-					      new_position + j);
+	      constructor_elt *f = VEC_index (constructor_elt, vid.inits,
+					      new_position - j);
 	      f->index = NULL_TREE;
 	      f->value = build1 (NOP_EXPR, vtable_entry_type,
 				 null_pointer_node);