PATCH: RFA reload.c patch

Jim Wilson wilson@specifixinc.com
Wed Nov 12 22:45:00 GMT 2003


On Wed, 2003-11-12 at 12:48, Eric Christopher wrote:
> Since your mail I did some checking and it looks that reg_equiv_address
> isn't verified using strict_address_p, only reg_equiv_mem is.

Right.  reg_equiv_address holds invalid addresses that reload believes
will be trivial to reload into valid addresses.

Notice in the aforementioned code there is a CONSTANT_P check, so any
reg_equiv_memory_loc with a constant address gets put in
reg_equiv_address, on the assumption that it is trivial to fix them,
presumably by loading the constant into a register.

> (mem:SF (symbol_ref/u ..LC0))
> 
> later in find_reloads_address after a lot of if/else if conditions we
> notice that the address isn't valid and send it down through
> find_reloads_address_part which immediately tries to force the it via
> force_const_mem and since it's a symbol_ref we don't allow that to
> happen and end up returning null and segfaulting there.

Calling force_const_mem is not useful here, since we already have a
constant pool address.  So something is going wrong in
find_reloads_address_part.  What should happen here is that the constant
should be loaded into a register.

I see in find_reloads_address_part that there is a test
  if (CONSTANT_P (x)
      && (! LEGITIMATE_CONSTANT_P (x)
          || PREFERRED_RELOAD_CLASS (x, class) == NO_REGS))

So I believe the correct fix here is to modify the code in reload() that
sets reg_equiv_address to use this check instead of just a CONSTANT_P
check as it does now.  Actually, we have to invert the second half of
this test, since we want to test for valid address constants there.

We also need the same change for the (PLUS (REG) CONSTANT) test in the
same place.

Your patch as it stands may result in worse code for targets that can
load symbol_refs into registers, which is why I think this should be
fixed differently.
-- 
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com



More information about the Gcc-patches mailing list