[gnu.gcc.bug] alter_reg assigns misaligned stack slots

cudcv@warwick.ac.uk (Rob McMahon) (09/26/88)

GCC 1.28, Gould PN6000

When a pseudo-reg gets spilt to a stack slot, alter_reg now tries to re-use a
slot which was previously allocated to the same hard reg.  If the mode was
different, though, this slot may have had an offset added by
assign_stack_local, which won't be appropriate for the current mode.  The
result is a misaligned stack slot, and a core dump on big-endian machines that
care about alignment.

The offset could probably be adjusted, but I've just punted and stopped it
reusing a stack slot allocated to a different mode.  Around line 1069 in
reload.c (alter_reg):

      if (from_reg == -1)
	x = assign_stack_local (GET_MODE (regno_reg_rtx[i]),
				PSEUDO_REGNO_BYTES (i));
=>    else if (spill_stack_slot[from_reg] != 0
=>	       && GET_MODE (regno_reg_rtx[i])
=>		  == GET_MODE (spill_stack_slot[from_reg]))
	x = spill_stack_slot[from_reg];
      else
	spill_stack_slot[from_reg] = x
	  = assign_stack_local (GET_MODE (regno_reg_rtx[i]),
				PSEUDO_REGNO_BYTES (i));

Rob
-- 
UUCP:   ...!mcvax!ukc!warwick!cudcv	PHONE:  +44 203 523037
JANET:  cudcv@uk.ac.warwick             ARPA:   cudcv@warwick.ac.uk
Rob McMahon, Computing Services, Warwick University, Coventry CV4 7AL, England