Commit a5b9bc17 by Richard Sandiford Committed by Richard Sandiford

cse.c (is_dead_reg): Change argument to const_rtx.

gcc/
	* cse.c (is_dead_reg): Change argument to const_rtx.
	(dead_debug_insn_data): Delete.
	(is_dead_debug_insn): Expand commentary.  Turn from being a
	for_each_rtx callback to being a function that examines
	each subrtx itself.  Take the fields of dead_debug_insn_data
	as argument.
	(delete_trivially_dead_insns): Update call accordingly.

From-SVN: r214630
parent f0002948
2014-08-28 Richard Sandiford <rdsandiford@googlemail.com> 2014-08-28 Richard Sandiford <rdsandiford@googlemail.com>
* cse.c (is_dead_reg): Change argument to const_rtx.
(dead_debug_insn_data): Delete.
(is_dead_debug_insn): Expand commentary. Turn from being a
for_each_rtx callback to being a function that examines
each subrtx itself. Take the fields of dead_debug_insn_data
as argument.
(delete_trivially_dead_insns): Update call accordingly.
2014-08-28 Richard Sandiford <rdsandiford@googlemail.com>
* cse.c (check_for_label_ref): Move earlier in file. Turn from * cse.c (check_for_label_ref): Move earlier in file. Turn from
being a for_each_rtx callback to being a function that examines being a for_each_rtx callback to being a function that examines
each subrtx itself. each subrtx itself.
......
...@@ -6784,7 +6784,7 @@ count_reg_usage (rtx x, int *counts, rtx dest, int incr) ...@@ -6784,7 +6784,7 @@ count_reg_usage (rtx x, int *counts, rtx dest, int incr)
/* Return true if X is a dead register. */ /* Return true if X is a dead register. */
static inline int static inline int
is_dead_reg (rtx x, int *counts) is_dead_reg (const_rtx x, int *counts)
{ {
return (REG_P (x) return (REG_P (x)
&& REGNO (x) >= FIRST_PSEUDO_REGISTER && REGNO (x) >= FIRST_PSEUDO_REGISTER
...@@ -6871,30 +6871,29 @@ count_stores (rtx x, const_rtx set ATTRIBUTE_UNUSED, void *data) ...@@ -6871,30 +6871,29 @@ count_stores (rtx x, const_rtx set ATTRIBUTE_UNUSED, void *data)
counts[REGNO (x)]++; counts[REGNO (x)]++;
} }
struct dead_debug_insn_data /* Return if DEBUG_INSN pattern PAT needs to be reset because some dead
{ pseudo doesn't have a replacement. COUNTS[X] is zero if register X
int *counts; is dead and REPLACEMENTS[X] is null if it has no replacemenet.
rtx *replacements; Set *SEEN_REPL to true if we see a dead register that does have
bool seen_repl; a replacement. */
};
/* Return if a DEBUG_INSN needs to be reset because some dead
pseudo doesn't have a replacement. Callback for for_each_rtx. */
static int static bool
is_dead_debug_insn (rtx *loc, void *data) is_dead_debug_insn (const_rtx pat, int *counts, rtx *replacements,
bool *seen_repl)
{ {
rtx x = *loc; subrtx_iterator::array_type array;
struct dead_debug_insn_data *ddid = (struct dead_debug_insn_data *) data; FOR_EACH_SUBRTX (iter, array, pat, NONCONST)
if (is_dead_reg (x, ddid->counts))
{ {
if (ddid->replacements && ddid->replacements[REGNO (x)] != NULL_RTX) const_rtx x = *iter;
ddid->seen_repl = true; if (is_dead_reg (x, counts))
{
if (replacements && replacements[REGNO (x)] != NULL_RTX)
*seen_repl = true;
else else
return 1; return true;
} }
return 0; }
return false;
} }
/* Replace a dead pseudo in a DEBUG_INSN with replacement DEBUG_EXPR. /* Replace a dead pseudo in a DEBUG_INSN with replacement DEBUG_EXPR.
...@@ -7038,22 +7037,19 @@ delete_trivially_dead_insns (rtx_insn *insns, int nreg) ...@@ -7038,22 +7037,19 @@ delete_trivially_dead_insns (rtx_insn *insns, int nreg)
if (MAY_HAVE_DEBUG_INSNS) if (MAY_HAVE_DEBUG_INSNS)
{ {
struct dead_debug_insn_data ddid;
ddid.counts = counts;
ddid.replacements = replacements;
for (insn = get_last_insn (); insn; insn = PREV_INSN (insn)) for (insn = get_last_insn (); insn; insn = PREV_INSN (insn))
if (DEBUG_INSN_P (insn)) if (DEBUG_INSN_P (insn))
{ {
/* If this debug insn references a dead register that wasn't replaced /* If this debug insn references a dead register that wasn't replaced
with an DEBUG_EXPR, reset the DEBUG_INSN. */ with an DEBUG_EXPR, reset the DEBUG_INSN. */
ddid.seen_repl = false; bool seen_repl = false;
if (for_each_rtx (&INSN_VAR_LOCATION_LOC (insn), if (is_dead_debug_insn (INSN_VAR_LOCATION_LOC (insn),
is_dead_debug_insn, &ddid)) counts, replacements, &seen_repl))
{ {
INSN_VAR_LOCATION_LOC (insn) = gen_rtx_UNKNOWN_VAR_LOC (); INSN_VAR_LOCATION_LOC (insn) = gen_rtx_UNKNOWN_VAR_LOC ();
df_insn_rescan (insn); df_insn_rescan (insn);
} }
else if (ddid.seen_repl) else if (seen_repl)
{ {
INSN_VAR_LOCATION_LOC (insn) INSN_VAR_LOCATION_LOC (insn)
= simplify_replace_fn_rtx (INSN_VAR_LOCATION_LOC (insn), = simplify_replace_fn_rtx (INSN_VAR_LOCATION_LOC (insn),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment