diff options
author | Bernd Schmidt <bernds@cygnus.co.uk> | 2000-04-30 13:37:15 +0000 |
---|---|---|
committer | Bernd Schmidt <crux@gcc.gnu.org> | 2000-04-30 13:37:15 +0000 |
commit | 4d0482f6eb8ad9ecc2e552a3285175c0cecc9c76 (patch) | |
tree | 74401fe9691dc4567fa3d84e3580a0ddb99d3bf9 /gcc | |
parent | a5c874cb0285942655bb8fcc71f4715c70cfb2ee (diff) | |
download | gcc-4d0482f6eb8ad9ecc2e552a3285175c0cecc9c76.zip gcc-4d0482f6eb8ad9ecc2e552a3285175c0cecc9c76.tar.gz gcc-4d0482f6eb8ad9ecc2e552a3285175c0cecc9c76.tar.bz2 |
Fix memory corruption bug
From-SVN: r33549
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 13 | ||||
-rw-r--r-- | gcc/simplify-rtx.c | 51 |
2 files changed, 34 insertions, 30 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0d19e4b..7d27953 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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. diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index a959557..e3508ef 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -106,7 +106,6 @@ static void unchain_one_value PARAMS ((cselib_val *)); 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)); @@ -2183,26 +2182,6 @@ get_value_hash (entry) 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 @@ -2218,7 +2197,7 @@ references_value_p (x, only_useless) int i, j; if (GET_CODE (x) == VALUE - && (! only_useless || CSELIB_VAL_PTR (x)->value == 0)) + && (! only_useless || CSELIB_VAL_PTR (x)->locs == 0)) return 1; for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--) @@ -2245,6 +2224,7 @@ discard_useless_locs (x, info) { cselib_val *v = (cselib_val *)*x; struct elt_loc_list **p = &v->locs; + int had_locs = v->locs != 0; while (*p) { @@ -2254,9 +2234,11 @@ discard_useless_locs (x, info) p = &(*p)->next; } - if (check_value_useless (v)) - values_became_useless = 1; - + if (had_locs && v->locs == 0) + { + n_useless_values++; + values_became_useless = 1; + } return 1; } @@ -2269,7 +2251,7 @@ discard_useless_values (x, info) { cselib_val *v = (cselib_val *)*x; - if (v->value == 0) + if (v->locs == 0) { htab_clear_slot (hash_table, x); unchain_one_value (v); @@ -2877,8 +2859,8 @@ cselib_invalidate_regno (regno, mode) break; } } - - check_value_useless (v); + if (v->locs == 0) + n_useless_values++; } } } @@ -2951,6 +2933,7 @@ cselib_invalidate_mem_1 (slot, info) 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) { @@ -2986,7 +2969,9 @@ cselib_invalidate_mem_1 (slot, info) unchain_one_elt_loc_list (p); } - check_value_useless (v); + if (had_locs && v->locs == 0) + n_useless_values++; + return 1; } @@ -3045,10 +3030,16 @@ cselib_record_set (dest, src_elt, dest_addr_elt) 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) - add_mem_for_addr (dest_addr_elt, src_elt, dest); + { + 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. */ |