This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: regrename doesn't take HARD_REGNO_CALL_PART_CLOBBERED into account
- To: gcc-patches at gcc dot gnu dot org
- Subject: Re: regrename doesn't take HARD_REGNO_CALL_PART_CLOBBERED into account
- From: Alexandre Oliva <aoliva at redhat dot com>
- Date: 18 Mar 2001 02:55:05 -0300
- Organization: GCC Team, Red Hat
- References: <or4rx051d9.fsf@guarana.lsd.ic.unicamp.br>
On Mar 11, 2001, Alexandre Oliva <aoliva@redhat.com> wrote:
> It is possible that regrename chooses a register that may be partially
> clobbered in function calls to replace one that is fully saved in the
> mode(s) in which the register is used. It shouldn't do it. This
> patch fixes it.
And this patch improves it, by not requiring a non-part-clobbered
register if the originally chosen register is part-clobbered. I've
also caught a few cases in global alloc that didn't take the macro
into account, which fixed a few additional bugs in that port. Tested
on a new port, yet to be contributed. Ok to install?
Index: gcc/ChangeLog
* regrename.c (regrename_optimize): Don't use a register that may
be part-clobbered in the used modes.
* global.c (find_reg): Ditto.
Index: gcc/regrename.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/regrename.c,v
retrieving revision 1.20
diff -u -p -r1.20 regrename.c
--- gcc/regrename.c 2001/01/04 14:17:38 1.20
+++ gcc/regrename.c 2001/03/18 05:51:18
@@ -1,5 +1,5 @@
/* Register renaming for the GNU compiler.
- Copyright (C) 2000 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2001 Free Software Foundation, Inc.
This file is part of GNU CC.
@@ -303,7 +303,12 @@ regrename_optimize ()
/* See whether it accepts all modes that occur in
definition and uses. */
for (tmp = this; tmp; tmp = tmp->next_use)
- if (! HARD_REGNO_MODE_OK (new_reg, GET_MODE (*tmp->loc)))
+ if (! HARD_REGNO_MODE_OK (new_reg, GET_MODE (*tmp->loc))
+ || (last->need_caller_save_reg
+ && ! (HARD_REGNO_CALL_PART_CLOBBERED
+ (reg, GET_MODE (*tmp->loc)))
+ && (HARD_REGNO_CALL_PART_CLOBBERED
+ (new_reg, GET_MODE (*tmp->loc)))))
break;
if (! tmp)
{
Index: gcc/global.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/global.c,v
retrieving revision 1.65
diff -u -p -r1.65 global.c
--- gcc/global.c 2000/12/05 19:12:19 1.65
+++ gcc/global.c 2001/03/18 05:51:18
@@ -1,6 +1,6 @@
/* Allocate registers for pseudo-registers that span basic blocks.
Copyright (C) 1987, 1988, 1991, 1994, 1996, 1997, 1998,
- 1999, 2000 Free Software Foundation, Inc.
+ 1999, 2000, 2001 Free Software Foundation, Inc.
This file is part of GNU CC.
@@ -1076,6 +1076,10 @@ find_reg (num, losers, alt_regs_p, accep
for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
if (TEST_HARD_REG_BIT (allocno[num].hard_reg_copy_preferences, i)
&& HARD_REGNO_MODE_OK (i, mode)
+ && (allocno[num].calls_crossed == 0
+ || accept_call_clobbered
+ || HARD_REGNO_CALL_PART_CLOBBERED (best_reg, mode)
+ || ! HARD_REGNO_CALL_PART_CLOBBERED (i, mode))
&& (REGNO_REG_CLASS (i) == REGNO_REG_CLASS (best_reg)
|| reg_class_subset_p (REGNO_REG_CLASS (i),
REGNO_REG_CLASS (best_reg))
@@ -1112,6 +1116,10 @@ find_reg (num, losers, alt_regs_p, accep
for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
if (TEST_HARD_REG_BIT (allocno[num].hard_reg_preferences, i)
&& HARD_REGNO_MODE_OK (i, mode)
+ && (allocno[num].calls_crossed == 0
+ || accept_call_clobbered
+ || HARD_REGNO_CALL_PART_CLOBBERED (best_reg, mode)
+ || ! HARD_REGNO_CALL_PART_CLOBBERED (i, mode))
&& (REGNO_REG_CLASS (i) == REGNO_REG_CLASS (best_reg)
|| reg_class_subset_p (REGNO_REG_CLASS (i),
REGNO_REG_CLASS (best_reg))
@@ -1192,6 +1200,9 @@ find_reg (num, losers, alt_regs_p, accep
/* Don't use a reg no good for this pseudo. */
&& ! TEST_HARD_REG_BIT (used2, regno)
&& HARD_REGNO_MODE_OK (regno, mode)
+ && (allocno[num].calls_crossed == 0
+ || accept_call_clobbered
+ || ! HARD_REGNO_CALL_PART_CLOBBERED (regno, mode))
#ifdef CLASS_CANNOT_CHANGE_MODE
&& ! (REG_CHANGES_MODE (allocno[num].reg)
&& (TEST_HARD_REG_BIT
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist *Please* write to mailing lists, not to me