summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2010-02-03 15:00:33 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2010-02-03 15:00:33 +0000
commit01df1184161c4861e2b58bcf7d47c740d40a6aa8 (patch)
treed1d02dd20ec7ed6126855d129131396ddfb171df
parent4ef43bbdd80b43a9843092db88a86bb5d4e9cc19 (diff)
downloadgcc-01df1184161c4861e2b58bcf7d47c740d40a6aa8.tar.gz
2010-02-03 Alexandre Oliva <aoliva@redhat.com>
PR debug/42896 * cselib.h (struct cselib_val_struct): Add uid. Rename value to hash. (cselib_reset_table): Renamed from... (cselib_reset_table_with_next_value): ... this. (cselib_get_next_uid): Renamed from... (cselib_get_next_unknown_value): ... this. * cselib.c (next_uid): Renamed from... (next_unknown_value): ... this. (cselib_clear_table): Adjust. (cselib_reset_table): Adjust. Renamed from... (cselib_reset_table_with_next_value): ... this. (cselib_get_next_uid): Adjust. Renamed from... (cselib_get_next_unknown_value): ... this. (get_value_hash): Use hash. (cselib_hash_rtx): Likewise. (new_cselib_val): Adjust. Set and dump uid. (cselib_lookup_mem): Pass next_uid as hash. (cselib_subst_to_values): Likewise. (cselib_log_lookup): Dump uid. (cselib_lookup): Pass next_uid as hash. Adjust. (cselib_process_insn): Adjust. (cselib_init): Initialize next_uid. (cselib_finish): Adjust. (dump_cselib_table): Likewise. * dse.c (canon_address): Dump value uid. * print-rtl.c (print_rtx): Print value uid. * var-tracking.c (VARIABLE_HASH_VAL): Dropped. (dvuid): New type. (dv_uid): New function, sort of renamed from... (dv_htab_hash): ... this, reimplemented in terms of it and... (dv_uid2hash): ... this. New. (variable_htab_eq): Drop excess assertions. (tie_break_pointers): Removed. (canon_value_cmp): Compare uids. (variable_post_merge_New_vals): Print uids. (vt_add_function_parameters): Adjust. (vt_initialize): Reset table. Adjust. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@156468 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog41
-rw-r--r--gcc/cselib.c51
-rw-r--r--gcc/cselib.h14
-rw-r--r--gcc/dse.c4
-rw-r--r--gcc/print-rtl.c2
-rw-r--r--gcc/var-tracking.c98
6 files changed, 118 insertions, 92 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 34437bd5a50..180d60431a1 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,44 @@
+2010-02-03 Alexandre Oliva <aoliva@redhat.com>
+
+ PR debug/42896
+ * cselib.h (struct cselib_val_struct): Add uid. Rename value to
+ hash.
+ (cselib_reset_table): Renamed from...
+ (cselib_reset_table_with_next_value): ... this.
+ (cselib_get_next_uid): Renamed from...
+ (cselib_get_next_unknown_value): ... this.
+ * cselib.c (next_uid): Renamed from...
+ (next_unknown_value): ... this.
+ (cselib_clear_table): Adjust.
+ (cselib_reset_table): Adjust. Renamed from...
+ (cselib_reset_table_with_next_value): ... this.
+ (cselib_get_next_uid): Adjust. Renamed from...
+ (cselib_get_next_unknown_value): ... this.
+ (get_value_hash): Use hash.
+ (cselib_hash_rtx): Likewise.
+ (new_cselib_val): Adjust. Set and dump uid.
+ (cselib_lookup_mem): Pass next_uid as hash.
+ (cselib_subst_to_values): Likewise.
+ (cselib_log_lookup): Dump uid.
+ (cselib_lookup): Pass next_uid as hash. Adjust.
+ (cselib_process_insn): Adjust.
+ (cselib_init): Initialize next_uid.
+ (cselib_finish): Adjust.
+ (dump_cselib_table): Likewise.
+ * dse.c (canon_address): Dump value uid.
+ * print-rtl.c (print_rtx): Print value uid.
+ * var-tracking.c (VARIABLE_HASH_VAL): Dropped.
+ (dvuid): New type.
+ (dv_uid): New function, sort of renamed from...
+ (dv_htab_hash): ... this, reimplemented in terms of it and...
+ (dv_uid2hash): ... this. New.
+ (variable_htab_eq): Drop excess assertions.
+ (tie_break_pointers): Removed.
+ (canon_value_cmp): Compare uids.
+ (variable_post_merge_New_vals): Print uids.
+ (vt_add_function_parameters): Adjust.
+ (vt_initialize): Reset table. Adjust.
+
2010-02-03 Richard Guenther <rguenther@suse.de>
PR tree-optimization/42944
diff --git a/gcc/cselib.c b/gcc/cselib.c
index 66d92a01ad0..deac835f933 100644
--- a/gcc/cselib.c
+++ b/gcc/cselib.c
@@ -89,8 +89,8 @@ static htab_t cselib_hash_table;
It is used in new_elt_loc_list to set SETTING_INSN. */
static rtx cselib_current_insn;
-/* Every new unknown value gets a unique number. */
-static unsigned int next_unknown_value;
+/* The unique id that the next create value will take. */
+static unsigned int next_uid;
/* The number of registers we had when the varrays were last resized. */
static unsigned int cselib_nregs;
@@ -227,14 +227,14 @@ unchain_one_value (cselib_val *v)
void
cselib_clear_table (void)
{
- cselib_reset_table_with_next_value (0);
+ cselib_reset_table (1);
}
/* Remove all entries from the hash table, arranging for the next
value to be numbered NUM. */
void
-cselib_reset_table_with_next_value (unsigned int num)
+cselib_reset_table (unsigned int num)
{
unsigned int i;
@@ -250,7 +250,7 @@ cselib_reset_table_with_next_value (unsigned int num)
n_useless_values = 0;
- next_unknown_value = num;
+ next_uid = num;
first_containing_mem = &dummy_val;
}
@@ -258,9 +258,9 @@ cselib_reset_table_with_next_value (unsigned int num)
/* Return the number of the next value that will be generated. */
unsigned int
-cselib_get_next_unknown_value (void)
+cselib_get_next_uid (void)
{
- return next_unknown_value;
+ return next_uid;
}
/* The equality test for our hash table. The first argument ENTRY is a table
@@ -306,7 +306,7 @@ static hashval_t
get_value_hash (const void *entry)
{
const cselib_val *const v = (const cselib_val *) entry;
- return v->value;
+ return v->hash;
}
/* Return true if X contains a VALUE rtx. If ONLY_USELESS is set, we
@@ -715,7 +715,7 @@ cselib_hash_rtx (rtx x, int create)
if (! e)
return 0;
- return e->value;
+ return e->hash;
case DEBUG_EXPR:
hash += ((unsigned) DEBUG_EXPR << 7)
@@ -866,13 +866,15 @@ cselib_hash_rtx (rtx x, int create)
value is MODE. */
static inline cselib_val *
-new_cselib_val (unsigned int value, enum machine_mode mode, rtx x)
+new_cselib_val (unsigned int hash, enum machine_mode mode, rtx x)
{
cselib_val *e = (cselib_val *) pool_alloc (cselib_val_pool);
- gcc_assert (value);
+ gcc_assert (hash);
+ gcc_assert (next_uid);
- e->value = value;
+ e->hash = hash;
+ e->uid = next_uid++;
/* We use an alloc pool to allocate this RTL construct because it
accounts for about 8% of the overall memory usage. We know
precisely when we can have VALUE RTXen (when cselib is active)
@@ -889,7 +891,7 @@ new_cselib_val (unsigned int value, enum machine_mode mode, rtx x)
if (dump_file && (dump_flags & TDF_DETAILS))
{
- fprintf (dump_file, "cselib value %u ", value);
+ fprintf (dump_file, "cselib value %u:%u ", e->uid, hash);
if (flag_dump_noaddr || flag_dump_unnumbered)
fputs ("# ", dump_file);
else
@@ -957,10 +959,10 @@ cselib_lookup_mem (rtx x, int create)
if (! create)
return 0;
- mem_elt = new_cselib_val (++next_unknown_value, mode, x);
+ mem_elt = new_cselib_val (next_uid, mode, x);
add_mem_for_addr (addr, mem_elt, x);
slot = htab_find_slot_with_hash (cselib_hash_table, wrap_constant (mode, x),
- mem_elt->value, INSERT);
+ mem_elt->hash, INSERT);
*slot = mem_elt;
return mem_elt;
}
@@ -1393,7 +1395,7 @@ cselib_subst_to_values (rtx x)
{
/* This happens for autoincrements. Assign a value that doesn't
match any other. */
- e = new_cselib_val (++next_unknown_value, GET_MODE (x), x);
+ e = new_cselib_val (next_uid, GET_MODE (x), x);
}
return e->val_rtx;
@@ -1409,7 +1411,7 @@ cselib_subst_to_values (rtx x)
case PRE_DEC:
case POST_MODIFY:
case PRE_MODIFY:
- e = new_cselib_val (++next_unknown_value, GET_MODE (x), x);
+ e = new_cselib_val (next_uid, GET_MODE (x), x);
return e->val_rtx;
default:
@@ -1463,7 +1465,9 @@ cselib_log_lookup (rtx x, cselib_val *ret)
{
fputs ("cselib lookup ", dump_file);
print_inline_rtx (dump_file, x, 2);
- fprintf (dump_file, " => %u\n", ret ? ret->value : 0);
+ fprintf (dump_file, " => %u:%u\n",
+ ret ? ret->uid : 0,
+ ret ? ret->hash : 0);
}
return ret;
@@ -1510,7 +1514,7 @@ cselib_lookup (rtx x, enum machine_mode mode, int create)
max_value_regs = n;
}
- e = new_cselib_val (++next_unknown_value, GET_MODE (x), x);
+ e = new_cselib_val (next_uid, GET_MODE (x), x);
e->locs = new_elt_loc_list (e->locs, x);
if (REG_VALUES (i) == 0)
{
@@ -1521,7 +1525,7 @@ cselib_lookup (rtx x, enum machine_mode mode, int create)
REG_VALUES (i) = new_elt_list (REG_VALUES (i), NULL);
}
REG_VALUES (i)->next = new_elt_list (REG_VALUES (i)->next, e);
- slot = htab_find_slot_with_hash (cselib_hash_table, x, e->value, INSERT);
+ slot = htab_find_slot_with_hash (cselib_hash_table, x, e->hash, INSERT);
*slot = e;
return cselib_log_lookup (x, e);
}
@@ -1961,7 +1965,7 @@ cselib_process_insn (rtx insn)
&& GET_CODE (PATTERN (insn)) == ASM_OPERANDS
&& MEM_VOLATILE_P (PATTERN (insn))))
{
- cselib_reset_table_with_next_value (next_unknown_value);
+ cselib_reset_table (next_uid);
return;
}
@@ -2057,6 +2061,7 @@ cselib_init (bool record_memory)
n_used_regs = 0;
cselib_hash_table = htab_create (31, get_value_hash,
entry_and_rtx_equal_p, NULL);
+ next_uid = 1;
}
/* Called when the current user is done with cselib. */
@@ -2075,7 +2080,7 @@ cselib_finish (void)
used_regs = 0;
cselib_hash_table = 0;
n_useless_values = 0;
- next_unknown_value = 0;
+ next_uid = 0;
}
/* Dump the cselib_val *X to FILE *info. */
@@ -2163,7 +2168,7 @@ dump_cselib_table (FILE *out)
print_inline_rtx (out, first_containing_mem->val_rtx, 2);
fputc ('\n', out);
}
- fprintf (out, "last unknown value %i\n", next_unknown_value);
+ fprintf (out, "next uid %i\n", next_uid);
}
#include "gt-cselib.h"
diff --git a/gcc/cselib.h b/gcc/cselib.h
index 433f4deb87d..75ff457bf2d 100644
--- a/gcc/cselib.h
+++ b/gcc/cselib.h
@@ -1,6 +1,7 @@
/* Common subexpression elimination for GNU compiler.
- Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+ Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997,
+ 1998, 1999, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+ Free Software Foundation, Inc.
This file is part of GCC.
@@ -21,7 +22,10 @@ along with GCC; see the file COPYING3. If not see
/* Describe a value. */
typedef struct GTY(()) cselib_val_struct {
/* The hash value. */
- unsigned int value;
+ unsigned int hash;
+
+ /* A unique id assigned to values. */
+ int uid;
/* A VALUE rtx that points back to this structure. */
rtx val_rtx;
@@ -81,8 +85,8 @@ extern rtx cselib_expand_value_rtx_cb (rtx, bitmap, int,
extern rtx cselib_subst_to_values (rtx);
extern void cselib_invalidate_rtx (rtx);
-extern void cselib_reset_table_with_next_value (unsigned int);
-extern unsigned int cselib_get_next_unknown_value (void);
+extern void cselib_reset_table (unsigned int);
+extern unsigned int cselib_get_next_uid (void);
extern void cselib_preserve_value (cselib_val *);
extern bool cselib_preserved_value_p (cselib_val *);
extern void cselib_preserve_only_values (bool);
diff --git a/gcc/dse.c b/gcc/dse.c
index 9569a6176e1..e72b998133e 100644
--- a/gcc/dse.c
+++ b/gcc/dse.c
@@ -1199,8 +1199,8 @@ canon_address (rtx mem,
return false;
}
if (dump_file)
- fprintf (dump_file, " varying cselib base=%d offset = %d\n",
- (*base)->value, (int)*offset);
+ fprintf (dump_file, " varying cselib base=%u:%u offset = %d\n",
+ (*base)->uid, (*base)->hash, (int)*offset);
return true;
}
diff --git a/gcc/print-rtl.c b/gcc/print-rtl.c
index 75f034376cb..52709da6ea0 100644
--- a/gcc/print-rtl.c
+++ b/gcc/print-rtl.c
@@ -316,7 +316,7 @@ print_rtx (const_rtx in_rtx)
#ifndef GENERATOR_FILE
cselib_val *val = CSELIB_VAL_PTR (in_rtx);
- fprintf (outfile, " %i", val->value);
+ fprintf (outfile, " %u:%u", val->uid, val->hash);
dump_addr (outfile, " @", in_rtx);
dump_addr (outfile, "/", (void*)val);
#endif
diff --git a/gcc/var-tracking.c b/gcc/var-tracking.c
index 58a11c1031b..7fa75748a54 100644
--- a/gcc/var-tracking.c
+++ b/gcc/var-tracking.c
@@ -345,9 +345,6 @@ typedef struct value_chain_def
} *value_chain;
typedef const struct value_chain_def *const_value_chain;
-/* Hash function for DECL for VARIABLE_HTAB. */
-#define VARIABLE_HASH_VAL(decl) (DECL_UID (decl))
-
/* Pointer to the BB's information specific to variable tracking pass. */
#define VTI(BB) ((variable_tracking_info) (BB)->aux)
@@ -820,13 +817,33 @@ dv_from_value (rtx value)
return dv;
}
-static inline hashval_t
-dv_htab_hash (decl_or_value dv)
+typedef unsigned int dvuid;
+
+/* Return the uid of DV. */
+
+static inline dvuid
+dv_uid (decl_or_value dv)
{
if (dv_is_value_p (dv))
- return -(hashval_t)(CSELIB_VAL_PTR (dv_as_value (dv))->value);
+ return CSELIB_VAL_PTR (dv_as_value (dv))->uid;
else
- return (VARIABLE_HASH_VAL (dv_as_decl (dv)));
+ return DECL_UID (dv_as_decl (dv));
+}
+
+/* Compute the hash from the uid. */
+
+static inline hashval_t
+dv_uid2hash (dvuid uid)
+{
+ return uid;
+}
+
+/* The hash function for a mask table in a shared_htab chain. */
+
+static inline hashval_t
+dv_htab_hash (decl_or_value dv)
+{
+ return dv_uid2hash (dv_uid (dv));
}
/* The hash function for variable_htab, computes the hash value
@@ -848,29 +865,7 @@ variable_htab_eq (const void *x, const void *y)
const_variable const v = (const_variable) x;
decl_or_value dv = CONST_CAST2 (decl_or_value, const void *, y);
- if (dv_as_opaque (v->dv) == dv_as_opaque (dv))
- return true;
-
-#if ENABLE_CHECKING
- {
- bool visv, dvisv;
-
- visv = dv_is_value_p (v->dv);
- dvisv = dv_is_value_p (dv);
-
- if (visv != dvisv)
- return false;
-
- if (visv)
- gcc_assert (CSELIB_VAL_PTR (dv_as_value (v->dv))
- != CSELIB_VAL_PTR (dv_as_value (dv)));
- else
- gcc_assert (VARIABLE_HASH_VAL (dv_as_decl (v->dv))
- != VARIABLE_HASH_VAL (dv_as_decl (dv)));
- }
-#endif
-
- return false;
+ return (dv_as_opaque (v->dv) == dv_as_opaque (dv));
}
/* Free the element of VARIABLE_HTAB (its type is struct variable_def). */
@@ -1151,23 +1146,6 @@ shared_hash_find (shared_hash vars, decl_or_value dv)
return shared_hash_find_1 (vars, dv, dv_htab_hash (dv));
}
-/* Determine a total order between two distinct pointers. Compare the
- pointers as integral types if size_t is wide enough, otherwise
- resort to bitwise memory compare. The actual order does not
- matter, we just need to be consistent, so endianness is
- irrelevant. */
-
-static int
-tie_break_pointers (const void *p1, const void *p2)
-{
- gcc_assert (p1 != p2);
-
- if (sizeof (size_t) >= sizeof (void*))
- return (size_t)p1 < (size_t)p2 ? -1 : 1;
- else
- return memcmp (&p1, &p2, sizeof (p1));
-}
-
/* Return true if TVAL is better than CVAL as a canonival value. We
choose lowest-numbered VALUEs, using the RTX address as a
tie-breaker. The idea is to arrange them into a star topology,
@@ -1181,9 +1159,7 @@ static inline bool
canon_value_cmp (rtx tval, rtx cval)
{
return !cval
- || CSELIB_VAL_PTR (tval)->value < CSELIB_VAL_PTR (cval)->value
- || (CSELIB_VAL_PTR (tval)->value == CSELIB_VAL_PTR (cval)->value
- && tie_break_pointers (tval, cval) < 0);
+ || CSELIB_VAL_PTR (tval)->uid < CSELIB_VAL_PTR (cval)->uid;
}
static bool dst_can_be_shared;
@@ -3563,8 +3539,8 @@ variable_post_merge_new_vals (void **slot, void *info)
cdv = dv_from_value (cval);
if (dump_file)
fprintf (dump_file,
- "Created new value %i for reg %i\n",
- v->value, REGNO (node->loc));
+ "Created new value %u:%u for reg %i\n",
+ v->uid, v->hash, REGNO (node->loc));
}
var_reg_decl_set (*dfpm->permp, node->loc,
@@ -7336,7 +7312,7 @@ vt_add_function_parameters (void)
if (MAY_HAVE_DEBUG_INSNS)
{
cselib_preserve_only_values (true);
- cselib_reset_table_with_next_value (cselib_get_next_unknown_value ());
+ cselib_reset_table (cselib_get_next_uid ());
}
}
@@ -7369,15 +7345,15 @@ vt_initialize (void)
rtx insn;
HOST_WIDE_INT pre, post = 0;
int count;
- unsigned int next_value_before = cselib_get_next_unknown_value ();
- unsigned int next_value_after = next_value_before;
+ unsigned int next_uid_before = cselib_get_next_uid ();
+ unsigned int next_uid_after = next_uid_before;
if (MAY_HAVE_DEBUG_INSNS)
{
cselib_record_sets_hook = count_with_sets;
if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, "first value: %i\n",
- cselib_get_next_unknown_value ());
+ cselib_get_next_uid ());
}
/* Count the number of micro operations. */
@@ -7432,12 +7408,12 @@ vt_initialize (void)
if (MAY_HAVE_DEBUG_INSNS)
{
cselib_preserve_only_values (false);
- next_value_after = cselib_get_next_unknown_value ();
- cselib_reset_table_with_next_value (next_value_before);
+ next_uid_after = cselib_get_next_uid ();
+ cselib_reset_table (next_uid_before);
cselib_record_sets_hook = add_with_sets;
if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, "first value: %i\n",
- cselib_get_next_unknown_value ());
+ cselib_get_next_uid ());
}
/* Add the micro-operations to the array. */
@@ -7496,8 +7472,8 @@ vt_initialize (void)
if (MAY_HAVE_DEBUG_INSNS)
{
cselib_preserve_only_values (true);
- gcc_assert (next_value_after == cselib_get_next_unknown_value ());
- cselib_reset_table_with_next_value (next_value_after);
+ gcc_assert (next_uid_after == cselib_get_next_uid ());
+ cselib_reset_table (next_uid_after);
cselib_record_sets_hook = NULL;
}
}