Illegitimate address in REG_EQUAL note: legal?
Ulrich Weigand
Ulrich.Weigand@de.ibm.com
Tue Mar 5 09:56:00 GMT 2002
Jan Hubicka wrote:
>> gcse constant-propagation can substitute a constant
>> term for a register into a memory address, with the
>> resulting address being illegitimate.
>
>I guess it is valid. We don't require REG_EQUIV expressions to match the
>target constraints, we want them to describe directly what is going on.
OK, I see.
>> Unfortunately, this note gets promoted to a REG_EQUIV
>> note later on, and when reload sees this note, it will
>> create a reg_equiv_address entry for the pseudo.
>
>I guess this is the problem - the REG_EQUIV notes have different
>meaning for pre-reload and for reload/postreload, so I guess
>somewhere here we should kill REG_EQUIV notes with values invalid
>for reload.
>
>SImilarry I would guess we should kill REG_EQUALs somewhere on
>the progress as well, as they are invalid and some passes
>common for post/pre reload, like cfg_cleanup may get confused.
It looks like reload assumes REG_EQUIV notes to be either a
MEM (which is then implicitly assumed to be a legitimate
memory operand), or else a constant or stack pointer offset
(as accepted by function_invariant_p).
So, I think that local-alloc should only convert such REG_EQUAL
notes to REG_EQUIV that fit these expectations. The following
patch implements this check (and fixes my test case).
Index: local-alloc.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/local-alloc.c,v
retrieving revision 1.102
diff -c -p -r1.102 local-alloc.c
*** local-alloc.c 2002/02/19 02:53:13 1.102
--- local-alloc.c 2002/03/05 17:37:49
*************** update_equiv_regs ()
*** 946,951 ****
--- 946,959 ----
if (note && GET_CODE (XEXP (note, 0)) == EXPR_LIST)
note = NULL_RTX;
+ /* Reload assumes that REG_EQUIV notes contain either a
+ legitimate memory operand, or else a constant rtx as
+ accepted by function_invariant_p. Take care to not
+ generate anything else. */
+ if (note && !memory_operand (XEXP (note, 0), VOIDmode)
+ && !function_invariant_p (XEXP (note, 0)))
+ note = NULL_RTX;
+
if (REG_N_SETS (regno) != 1
&& (! note
|| rtx_varies_p (XEXP (note, 0), 0)
Do you think this could be a step in the right direction? I don't
completely understand all the implicit assumptions made by reload
and others, so I'm somewhat hesitant here ...
Mit freundlichen Gruessen / Best Regards
Ulrich Weigand
--
Dr. Ulrich Weigand
Linux for S/390 Design & Development
IBM Deutschland Entwicklung GmbH, Schoenaicher Str. 220, 71032 Boeblingen
Phone: +49-7031/16-3727 --- Email: Ulrich.Weigand@de.ibm.com
More information about the Gcc
mailing list