This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: PR 8757


Hello,
The attached patch changes splay_tree_key and splay_tree_value from
"unsigned long" to "void *". Quite a few parts of GCC implicitly assume
these two are the same (e.g. by passing (splay_tree_delete_value_fn)free
or (splay_tree_compare_fn)strcmp), which causes problems when
sizeof (long) != sizeof (void *), encountered in PR 8757.

The patch is against CVS HEAD as of Mar 15 2004, bootstrapped and
regression tested on i686-pc-linux-gnu with no new failures
(actually, libstdc++/22_locale/locale/cons/12658_thread.cc execution test
failed without this patch and didn't fail with it, but that seems to be just
an accident).

Testing on the platform of PR 8757 is not currently possible (that platform
is dead), but the failure reason (assuming splay_tree_value has the same
size as char *) is "obviously" eliminated.

Please keep me cc:ed, I'm not subscribed to any of the gcc lists.
Thanks,
	Mirek
2004-03-16  Miloslav Trmac  <mitr@volny.cz>

	* gcc/flow.c (mark_regno_cond_dead,flush_reg_cond_reg, mark_used_reg):
	Add casts to splay_tree_key.
	* include/splay-tree.h: Change splay_tree_key and splay_tree_value
	to void *.

diff -drp -C 3 gcc_orig/gcc/flow.c gcc/gcc/flow.c
*** gcc_orig/gcc/flow.c	2004-03-15 17:55:47.000000000 +0100
--- gcc/gcc/flow.c	2004-03-15 18:47:33.000000000 +0100
*************** mark_regno_cond_dead (struct propagate_b
*** 2916,2922 ****
    /* If this is an unconditional store, remove any conditional
       life that may have existed.  */
    if (cond == NULL_RTX)
!     splay_tree_remove (pbi->reg_cond_dead, regno);
    else
      {
        splay_tree_node node;
--- 2916,2922 ----
    /* If this is an unconditional store, remove any conditional
       life that may have existed.  */
    if (cond == NULL_RTX)
!     splay_tree_remove (pbi->reg_cond_dead, (splay_tree_key)regno);
    else
      {
        splay_tree_node node;
*************** mark_regno_cond_dead (struct propagate_b
*** 2927,2933 ****
  	 It may have been conditionally used, or there may be a
  	 subsequent set with a complimentary condition.  */
  
!       node = splay_tree_lookup (pbi->reg_cond_dead, regno);
        if (node == NULL)
  	{
  	  /* The register was unconditionally live previously.
--- 2927,2933 ----
  	 It may have been conditionally used, or there may be a
  	 subsequent set with a complimentary condition.  */
  
!       node = splay_tree_lookup (pbi->reg_cond_dead, (splay_tree_key)regno);
        if (node == NULL)
  	{
  	  /* The register was unconditionally live previously.
*************** mark_regno_cond_dead (struct propagate_b
*** 2937,2943 ****
  	  rcli->condition = cond;
  	  rcli->stores = cond;
  	  rcli->orig_condition = const0_rtx;
! 	  splay_tree_insert (pbi->reg_cond_dead, regno,
  			     (splay_tree_value) rcli);
  
  	  SET_REGNO_REG_SET (pbi->reg_cond_reg, REGNO (XEXP (cond, 0)));
--- 2937,2943 ----
  	  rcli->condition = cond;
  	  rcli->stores = cond;
  	  rcli->orig_condition = const0_rtx;
! 	  splay_tree_insert (pbi->reg_cond_dead, (splay_tree_key)regno,
  			     (splay_tree_value) rcli);
  
  	  SET_REGNO_REG_SET (pbi->reg_cond_reg, REGNO (XEXP (cond, 0)));
*************** mark_regno_cond_dead (struct propagate_b
*** 2967,2973 ****
  	     compare.  */
  	  if (ncond == const1_rtx
  	      || (ncond == rcli->orig_condition && rcli->stores == const1_rtx))
! 	    splay_tree_remove (pbi->reg_cond_dead, regno);
  	  else
  	    {
  	      rcli->condition = ncond;
--- 2967,2973 ----
  	     compare.  */
  	  if (ncond == const1_rtx
  	      || (ncond == rcli->orig_condition && rcli->stores == const1_rtx))
! 	    splay_tree_remove (pbi->reg_cond_dead, (splay_tree_key)regno);
  	  else
  	    {
  	      rcli->condition = ncond;
*************** flush_reg_cond_reg (struct propagate_blo
*** 3035,3041 ****
    pair[1] = -1;
    while (splay_tree_foreach (pbi->reg_cond_dead,
  			     flush_reg_cond_reg_1, pair) == -1)
!     splay_tree_remove (pbi->reg_cond_dead, pair[1]);
  
    CLEAR_REGNO_REG_SET (pbi->reg_cond_reg, regno);
  }
--- 3035,3041 ----
    pair[1] = -1;
    while (splay_tree_foreach (pbi->reg_cond_dead,
  			     flush_reg_cond_reg_1, pair) == -1)
!     splay_tree_remove (pbi->reg_cond_dead, (splay_tree_key)pair[1]);
  
    CLEAR_REGNO_REG_SET (pbi->reg_cond_reg, regno);
  }
*************** mark_used_reg (struct propagate_block_in
*** 3703,3709 ****
  
  	  if (this_was_live)
  	    {
! 	      node = splay_tree_lookup (pbi->reg_cond_dead, i);
  	      if (node == NULL)
  		{
  		  /* The register was unconditionally live previously.
--- 3703,3709 ----
  
  	  if (this_was_live)
  	    {
! 	      node = splay_tree_lookup (pbi->reg_cond_dead, (splay_tree_key)i);
  	      if (node == NULL)
  		{
  		  /* The register was unconditionally live previously.
*************** mark_used_reg (struct propagate_block_in
*** 3720,3726 ****
  		  /* If the register is now unconditionally live,
  		     remove the entry in the splay_tree.  */
  		  if (ncond == const0_rtx)
! 		    splay_tree_remove (pbi->reg_cond_dead, i);
  		  else
  		    {
  		      rcli->condition = ncond;
--- 3720,3726 ----
  		  /* If the register is now unconditionally live,
  		     remove the entry in the splay_tree.  */
  		  if (ncond == const0_rtx)
! 		    splay_tree_remove (pbi->reg_cond_dead, (splay_tree_key)i);
  		  else
  		    {
  		      rcli->condition = ncond;
*************** mark_used_reg (struct propagate_block_in
*** 3737,3743 ****
  	      rcli->condition = not_reg_cond (cond);
  	      rcli->stores = const0_rtx;
  	      rcli->orig_condition = const0_rtx;
! 	      splay_tree_insert (pbi->reg_cond_dead, i,
  				 (splay_tree_value) rcli);
  
  	      SET_REGNO_REG_SET (pbi->reg_cond_reg, REGNO (XEXP (cond, 0)));
--- 3737,3743 ----
  	      rcli->condition = not_reg_cond (cond);
  	      rcli->stores = const0_rtx;
  	      rcli->orig_condition = const0_rtx;
! 	      splay_tree_insert (pbi->reg_cond_dead, (splay_tree_key)i,
  				 (splay_tree_value) rcli);
  
  	      SET_REGNO_REG_SET (pbi->reg_cond_reg, REGNO (XEXP (cond, 0)));
*************** mark_used_reg (struct propagate_block_in
*** 3749,3755 ****
  	     is now unconditionally live.  Remove it from the conditionally
  	     dead list, so that a conditional set won't cause us to think
  	     it dead.  */
! 	  splay_tree_remove (pbi->reg_cond_dead, i);
  	}
  #endif
      }
--- 3749,3755 ----
  	     is now unconditionally live.  Remove it from the conditionally
  	     dead list, so that a conditional set won't cause us to think
  	     it dead.  */
! 	  splay_tree_remove (pbi->reg_cond_dead, (splay_tree_key)i);
  	}
  #endif
      }
diff -drp -C 3 gcc_orig/include/splay-tree.h gcc/include/splay-tree.h
*** gcc_orig/include/splay-tree.h	2004-03-15 17:56:00.000000000 +0100
--- gcc/include/splay-tree.h	2004-03-15 19:11:01.000000000 +0100
*************** extern "C" {
*** 43,51 ****
  /* Use typedefs for the key and data types to facilitate changing
     these types, if necessary.  These types should be sufficiently wide
     that any pointer or scalar can be cast to these types, and then
!    cast back, without loss of precision.  */
! typedef unsigned long int splay_tree_key;
! typedef unsigned long int splay_tree_value;
  
  /* Forward declaration for a node in the tree.  */
  typedef struct splay_tree_node_s *splay_tree_node;
--- 43,52 ----
  /* Use typedefs for the key and data types to facilitate changing
     these types, if necessary.  These types should be sufficiently wide
     that any pointer or scalar can be cast to these types, and then
!    cast back, without loss of precision.
!    Update also struct splay_tree_node below! */
! typedef void *splay_tree_key;
! typedef void *splay_tree_value;
  
  /* Forward declaration for a node in the tree.  */
  typedef struct splay_tree_node_s *splay_tree_node;
*************** typedef void (*splay_tree_deallocate_fn)
*** 81,90 ****
  struct splay_tree_node_s GTY(())
  {
    /* The key.  */
!   splay_tree_key GTY ((use_param1 (""))) key;
  
    /* The value.  */
!   splay_tree_value GTY ((use_param2 (""))) value;
  
    /* The left and right children, respectively.  */
    splay_tree_node GTY ((use_params (""))) left;
--- 82,91 ----
  struct splay_tree_node_s GTY(())
  {
    /* The key.  */
!   /* splay_tree_key */ void * GTY ((use_param1 (""))) key;
  
    /* The value.  */
!   /* splay_tree_value */ void * GTY ((use_param2 (""))) value;
  
    /* The left and right children, respectively.  */
    splay_tree_node GTY ((use_params (""))) left;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]