Compiler crash in cselib_invalidate_regno() patch

Bernd Schmidt bernds@balti.cygnus.co.uk
Sun Apr 30 06:42:00 GMT 2000


On Sun, 30 Apr 2000, Richard Henderson wrote:

> On Sat, Apr 29, 2000 at 04:09:16PM +0100, Bernd Schmidt wrote:
> > OK to install if it bootstraps?
> 
> Yep.

Well, that one didn't bootstrap, but the variant below did.  I've checked
this in.

Bernd

Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/egcs/gcc/ChangeLog,v
retrieving revision 1.6416
diff -c -p -r1.6416 ChangeLog
*** ChangeLog	2000/04/30 11:17:12	1.6416
--- ChangeLog	2000/04/30 13:33:35
***************
*** 1,3 ****
--- 1,16 ----
+ 2000-04-30  Bernd Schmidt  <bernds@cygnus.co.uk>
+ 
+ 	* simplify-rtx.c (check_value_useless): Delete function.
+ 	(discard_useless_locs): Don't call it; manage N_USELES_VALUES counter
+ 	by hand.
+ 	(cselib_invalidate_regno): Likewise.
+ 	(cselib_invalidate_mem_1): Likewise.
+ 	(references_value_p): Recognize useless values by the fact that they
+ 	have no locations.
+ 	(discard_useless_values): Likewise.
+ 	(cselib_record_set): This may turn a useless value
+ 	into a useful one.
+ 	
  2000-04-30  Richard Henderson  <rth@cygnus.com>
  
  	* config/d30v: New port.
Index: simplify-rtx.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/simplify-rtx.c,v
retrieving revision 1.13
diff -c -p -r1.13 simplify-rtx.c
*** simplify-rtx.c	2000/04/18 20:42:00	1.13
--- simplify-rtx.c	2000/04/30 13:33:38
*************** static void unchain_one_value		PARAMS ((
*** 106,112 ****
  static void unchain_one_elt_list	PARAMS ((struct elt_list **));
  static void unchain_one_elt_loc_list	PARAMS ((struct elt_loc_list **));
  static void clear_table			PARAMS ((void));
- static int check_value_useless		PARAMS ((cselib_val *));
  static int discard_useless_locs		PARAMS ((void **, void *));
  static int discard_useless_values	PARAMS ((void **, void *));
  static void remove_useless_values	PARAMS ((void));
--- 106,111 ----
*************** get_value_hash (entry)
*** 2183,2208 ****
    return v->value;
  }
  
- /* If there are no more locations that hold a value, the value has become
-    useless.  See whether that is the case for V.  Return 1 if this has
-    just become useless.  */
- 
- static int
- check_value_useless (v)
-      cselib_val *v;
- {
-   if (v->locs != 0)
-     return 0;
- 
-   if (v->value == 0)
-     return 0;
- 
-   /* This is a marker to indicate that the value will be reclaimed.  */
-   v->value = 0;
-   n_useless_values++;
-   return 1;
- }
- 
  /* Return true if X contains a VALUE rtx.  If ONLY_USELESS is set, we
     only return true for values which point to a cselib_val whose value
     element has been set to zero, which implies the cselib_val will be
--- 2182,2187 ----
*************** references_value_p (x, only_useless)
*** 2218,2224 ****
    int i, j;
  
    if (GET_CODE (x) == VALUE
!       && (! only_useless || CSELIB_VAL_PTR (x)->value == 0))
      return 1;
  
    for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
--- 2197,2203 ----
    int i, j;
  
    if (GET_CODE (x) == VALUE
!       && (! only_useless || CSELIB_VAL_PTR (x)->locs == 0))
      return 1;
  
    for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
*************** discard_useless_locs (x, info)
*** 2245,2250 ****
--- 2224,2230 ----
  {
    cselib_val *v = (cselib_val *)*x;
    struct elt_loc_list **p = &v->locs;
+   int had_locs = v->locs != 0;
  
    while (*p)
      {
*************** discard_useless_locs (x, info)
*** 2253,2262 ****
        else
  	p = &(*p)->next;
      }
- 
-   if (check_value_useless (v))
-     values_became_useless = 1;
  
    return 1;
  }
  
--- 2233,2244 ----
        else
  	p = &(*p)->next;
      }
  
+   if (had_locs && v->locs == 0)
+     {
+       n_useless_values++;
+       values_became_useless = 1;
+     }
    return 1;
  }
  
*************** discard_useless_values (x, info)
*** 2269,2275 ****
  {
    cselib_val *v = (cselib_val *)*x;
  
!   if (v->value == 0)
      {
        htab_clear_slot (hash_table, x);
        unchain_one_value (v);
--- 2251,2257 ----
  {
    cselib_val *v = (cselib_val *)*x;
  
!   if (v->locs == 0)
      {
        htab_clear_slot (hash_table, x);
        unchain_one_value (v);
*************** cselib_invalidate_regno (regno, mode)
*** 2877,2884 ****
  		  break;
  		}
  	    }
! 
! 	  check_value_useless (v);
  	}
      }
  }
--- 2859,2866 ----
  		  break;
  		}
  	    }
! 	  if (v->locs == 0)
! 	    n_useless_values++;
  	}
      }
  }
*************** cselib_invalidate_mem_1 (slot, info)
*** 2951,2956 ****
--- 2933,2939 ----
    cselib_val *v = (cselib_val *) *slot;
    rtx mem_rtx = (rtx) info;
    struct elt_loc_list **p = &v->locs;
+   int had_locs = v->locs != 0;
  
    while (*p)
      {
*************** cselib_invalidate_mem_1 (slot, info)
*** 2985,2992 ****
  
        unchain_one_elt_loc_list (p);
      }
  
-   check_value_useless (v);
    return 1;
  }
  
--- 2968,2977 ----
  
        unchain_one_elt_loc_list (p);
      }
+ 
+   if (had_locs && v->locs == 0)
+     n_useless_values++;
  
    return 1;
  }
  
*************** cselib_record_set (dest, src_elt, dest_a
*** 3045,3054 ****
    if (dreg >= 0)
      {
        REG_VALUES (dreg) = new_elt_list (REG_VALUES (dreg), src_elt);
        src_elt->locs = new_elt_loc_list (src_elt->locs, dest);
      }
    else if (GET_CODE (dest) == MEM && dest_addr_elt != 0)
!     add_mem_for_addr (dest_addr_elt, src_elt, dest);
  }
  
  /* Describe a single set that is part of an insn.  */
--- 3030,3045 ----
    if (dreg >= 0)
      {
        REG_VALUES (dreg) = new_elt_list (REG_VALUES (dreg), src_elt);
+       if (src_elt->locs == 0)
+ 	n_useless_values--;
        src_elt->locs = new_elt_loc_list (src_elt->locs, dest);
      }
    else if (GET_CODE (dest) == MEM && dest_addr_elt != 0)
!     {
!       if (src_elt->locs == 0)
! 	n_useless_values--;
!       add_mem_for_addr (dest_addr_elt, src_elt, dest);
!     }
  }
  
  /* Describe a single set that is part of an insn.  */



More information about the Gcc-patches mailing list