re PR rtl-optimization/52629 (out-of-bounds access in reload1.c)

PR rtl-optimization/52629
	* reload1.c (count_pseudo): Short-circuit common case.
	(count_spilled_pseudo): Return early for pseudos without hard regs.
	Assert that the pseudo has got a hard reg before manipulating it.

From-SVN: r185787
This commit is contained in:
Eric Botcazou 2012-03-26 08:41:02 +00:00 committed by Eric Botcazou
parent dd03252e94
commit 2169f14c29
2 changed files with 22 additions and 9 deletions

View File

@ -1,3 +1,10 @@
2012-03-26 Eric Botcazou <ebotcazou@adacore.com>
PR rtl-optimization/52629
* reload1.c (count_pseudo): Short-circuit common case.
(count_spilled_pseudo): Return early for pseudos without hard regs.
Assert that the pseudo has got a hard reg before manipulating it.
2012-03-24 Jan Hubicka <jh@suse.cz> 2012-03-24 Jan Hubicka <jh@suse.cz>
PR lto/51663 PR lto/51663

View File

@ -1746,11 +1746,12 @@ count_pseudo (int reg)
int r = reg_renumber[reg]; int r = reg_renumber[reg];
int nregs; int nregs;
/* Ignore spilled pseudo-registers which can be here only if IRA is used. */
if (ira_conflicts_p && r < 0)
return;
if (REGNO_REG_SET_P (&pseudos_counted, reg) if (REGNO_REG_SET_P (&pseudos_counted, reg)
|| REGNO_REG_SET_P (&spilled_pseudos, reg) || REGNO_REG_SET_P (&spilled_pseudos, reg))
/* Ignore spilled pseudo-registers which can be here only if IRA
is used. */
|| (ira_conflicts_p && r < 0))
return; return;
SET_REGNO_REG_SET (&pseudos_counted, reg); SET_REGNO_REG_SET (&pseudos_counted, reg);
@ -1827,12 +1828,17 @@ count_spilled_pseudo (int spilled, int spilled_nregs, int reg)
{ {
int freq = REG_FREQ (reg); int freq = REG_FREQ (reg);
int r = reg_renumber[reg]; int r = reg_renumber[reg];
int nregs = hard_regno_nregs[r][PSEUDO_REGNO_MODE (reg)]; int nregs;
/* Ignore spilled pseudo-registers which can be here only if IRA is /* Ignore spilled pseudo-registers which can be here only if IRA is used. */
used. */ if (ira_conflicts_p && r < 0)
if ((ira_conflicts_p && r < 0) return;
|| REGNO_REG_SET_P (&spilled_pseudos, reg)
gcc_assert (r >= 0);
nregs = hard_regno_nregs[r][PSEUDO_REGNO_MODE (reg)];
if (REGNO_REG_SET_P (&spilled_pseudos, reg)
|| spilled + spilled_nregs <= r || r + nregs <= spilled) || spilled + spilled_nregs <= r || r + nregs <= spilled)
return; return;