diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2012-03-26 08:41:02 +0000 |
---|---|---|
committer | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2012-03-26 08:41:02 +0000 |
commit | 2169f14c299675e237f066ee5d679e8ec504026d (patch) | |
tree | 9348ec306232214e21510616872803e11b9f6a02 | |
parent | dd03252e94757eb27d54ce78d32474b142d3692a (diff) | |
download | gcc-2169f14c299675e237f066ee5d679e8ec504026d.zip gcc-2169f14c299675e237f066ee5d679e8ec504026d.tar.gz gcc-2169f14c299675e237f066ee5d679e8ec504026d.tar.bz2 |
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
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/reload1.c | 24 |
2 files changed, 22 insertions, 9 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0db9147..bc16917 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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> PR lto/51663 diff --git a/gcc/reload1.c b/gcc/reload1.c index bbb75c8..71cea81 100644 --- a/gcc/reload1.c +++ b/gcc/reload1.c @@ -1746,11 +1746,12 @@ count_pseudo (int reg) int r = reg_renumber[reg]; 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) - || 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)) + || REGNO_REG_SET_P (&spilled_pseudos, reg)) return; 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 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 used. */ + if (ira_conflicts_p && r < 0) + return; + + gcc_assert (r >= 0); + + nregs = hard_regno_nregs[r][PSEUDO_REGNO_MODE (reg)]; - /* Ignore spilled pseudo-registers which can be here only if IRA is - used. */ - if ((ira_conflicts_p && r < 0) - || REGNO_REG_SET_P (&spilled_pseudos, reg) + if (REGNO_REG_SET_P (&spilled_pseudos, reg) || spilled + spilled_nregs <= r || r + nregs <= spilled) return; |