[gnu.gcc.bug] gcc-1.30 bug in copy_rtx_if_shared

jonathan@comp.vuw.ac.nz (Jonathan) (11/28/88)

[[ Please mail any replies to me; we don't get the mailing list here.
   Apologies if this has been fixed already. ]] 

Summary::
	Function copy_rtx_if_shared () in GCC-1.30 contains references
	to XEP(x, 1) of rtx x, when RTX_CODE(x) == MEM.
	Since rtx_length[MEM] == 1, this must be wrong.

Symptom::
	GCC 1.30, built with my Pyramid machine description, on a Vax,
	as a cross-compiler, dumps core when compiling function calls that
	pass more than 12 arguments to the callee. (Pyramids provide
        12 registers for passing arguments.)

Repeat-By::
	Tricky, without the Pyramid machine description.
	Hence the following:
	
Diagnosis::
	Gdb shows that cc1 is dying in copy_rtx_if_shared(), on the
	indicated line:

            case MEM:
        	[... code omitted ...]
              if (GET_CODE (XEXP (x, 0)) == REG
        	  && (REGNO (XEXP (x, 0)) == FRAME_POINTER_REGNUM
        	      || REGNO (XEXP (x, 0)) == ARG_POINTER_REGNUM)
=>        	  && CONSTANT_ADDRESS_P (XEXP (x, 1)))
                return x;                         ^
                                                  |
                                                 huh???

	MEMs only have one field.  Surely this code is bogus.

	Using the gdb and the -dr flag to cc1, x points to the MEM
	part of the rtl generated to pass the 13th argument:
                (insn 63 62 64 (set (mem:SI (reg:SI 14))
                       (const_int 13)) -1 (nil)
                   (nil))
	[[Register 14 is the data stack/argument pointer.]]


Fix-By:
	Removing the if() and return included above is surely safe, but will
	result in unnecessary copying of shared structure.  There must
	be a better fix.

	It's hard to come up with one, since I don't understand	what
	the original code was intended to do.  Perhaps

              if (GET_CODE (XEXP (x, 0)) == REG
        	  && (REGNO (XEXP (x, 0)) == FRAME_POINTER_REGNUM
        	      || REGNO (XEXP (x, 0)) == ARG_POINTER_REGNUM))

	is correct?