This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Instantiate virtual args in function-call usage
On Jan 11, 2001, Richard Henderson <rth@redhat.com> wrote:
> On Thu, Jan 11, 2001 at 09:31:36PM -0200, Alexandre Oliva wrote:
>> > Surely eliminate_regs_in_insn needs changes as well?
>>
>> I didn't find a need for it. Maybe just because reload() cleans up
>> afterwards?
> Oh, nevermind. You call eliminate_regs yourself while
> fixing things up. And of course function_usage things
> aren't used during reload itself.
> The patch is fine.
Not as much as I'd like. I've just found one corner case in which it
wouldn't work correctly. In this case, the register was found to be
equivalent to a SYMBOL_REF, for which CONSTANT_P didn't hold, so
eliminate_regs() wouldn't replace it. Later on, the location would be
replaced with regno_reg_rtx, that turned out to refer to the register
itself. Oops.
Here's a patch that makes sure this doesn't happen, and covers
constants and invalid addresses too (which should be fine for call
usage).
Ok to install?
Index: gcc/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
* reload1.c (replace_pseudos_in_call_usage): Use
reg_equiv_constant and reg_equiv_address, and don't try
regno_reg_rtx first.
Index: gcc/reload1.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/reload1.c,v
retrieving revision 1.251
diff -u -p -r1.251 reload1.c
--- gcc/reload1.c 2001/01/12 21:58:56 1.251
+++ gcc/reload1.c 2001/01/13 09:57:56
@@ -598,7 +598,9 @@ replace_pseudos_in_call_usage (loc, mem_
code = GET_CODE (x);
if (code == REG)
{
- if (REGNO (x) < FIRST_PSEUDO_REGISTER)
+ int regno = REGNO (x);
+
+ if (regno < FIRST_PSEUDO_REGISTER)
return;
x = eliminate_regs (x, mem_mode, usage);
@@ -609,10 +611,15 @@ replace_pseudos_in_call_usage (loc, mem_
return;
}
- if (reg_renumber [REGNO (x)] < 0)
- *loc = regno_reg_rtx[REGNO (x)];
- else if (reg_equiv_mem[REGNO (x)])
- *loc = reg_equiv_mem[REGNO (x)];
+ if (reg_equiv_constant[regno])
+ *loc = reg_equiv_constant[regno];
+ else if (reg_equiv_mem[regno])
+ *loc = reg_equiv_mem[regno];
+ else if (reg_equiv_address[regno])
+ *loc = gen_rtx_MEM (GET_MODE (x), reg_equiv_address[regno]);
+ else if (GET_CODE (regno_reg_rtx[regno]) != REG
+ || REGNO (regno_reg_rtx[regno]) != regno)
+ *loc = regno_reg_rtx[regno];
else
abort ();
--
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