This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RFA: Test recog_data.operand_loc in cleanup_subreg_operands()


Hi Guys,

  I would like to get approval for the following patch.  It fixes a
  seg fault in gcc when compiling the big-endian version of newlib for
  arm-elf.  The function cleanup_subreg_operands() was testing the
  CODE of recog_data.operand[i] but passing recog_data.operand_loc[i].

  In the particular case of the arm-elf build these the RTX pointed to
  by recog_data.operand_loc[i] was the REG inside the SUBREG held in 
  recog_data.operand[i].  (Is this a bug, I am not sure ?)  Thus
  alter_subreg tried to use SUBREG_REG on a REG, which produced a
  bogus pointer.

  To fix this I just followed the example of the for-loop for
  examining recog_data.dup_loc[] which is further down in
  cleanup_subreg_operands, and made the test look at the contents of
  recog_data.operand_loc[] instead of recog_data.operand[].

  Since it seemed reasonable, I also created a local variable to hold
  this rtx.  I think it makes the code a little cleaner.

May I apply this patch ?

Cheers
        Nick


2001-11-28  Nick Clifton  <nickc@cambridge.redhat.com>

	* final.c (cleanup_subreg_operands): Test the contents of
	recog_data.operand_loc[] and not recog_data.operand[].

Index: gcc/final.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/final.c,v
retrieving revision 1.225
diff -p -c -r1.225 final.c
*** final.c	2001/11/26 13:02:16	1.225
--- final.c	2001/11/28 15:00:30
*************** cleanup_subreg_operands (insn)
*** 3001,3024 ****
       rtx insn;
  {
    int i;
    extract_insn_cached (insn);
    for (i = 0; i < recog_data.n_operands; i++)
      {
!       if (GET_CODE (recog_data.operand[i]) == SUBREG)
! 	recog_data.operand[i] = alter_subreg (recog_data.operand_loc[i]);
!       else if (GET_CODE (recog_data.operand[i]) == PLUS
! 	       || GET_CODE (recog_data.operand[i]) == MULT
! 	       || GET_CODE (recog_data.operand[i]) == MEM)
  	recog_data.operand[i] = walk_alter_subreg (recog_data.operand_loc[i]);
      }
  
    for (i = 0; i < recog_data.n_dups; i++)
      {
!       if (GET_CODE (*recog_data.dup_loc[i]) == SUBREG)
  	*recog_data.dup_loc[i] = alter_subreg (recog_data.dup_loc[i]);
!       else if (GET_CODE (*recog_data.dup_loc[i]) == PLUS
! 	       || GET_CODE (*recog_data.dup_loc[i]) == MULT
! 	       || GET_CODE (*recog_data.dup_loc[i]) == MEM)
  	*recog_data.dup_loc[i] = walk_alter_subreg (recog_data.dup_loc[i]);
      }
  }
--- 3001,3029 ----
       rtx insn;
  {
    int i;
+ 
    extract_insn_cached (insn);
    for (i = 0; i < recog_data.n_operands; i++)
      {
!       rtx op = *recog_data.operand_loc[i];
! 
!       if (GET_CODE (op) == SUBREG)
! 	recog_data.operand[i] = alter_subreg (op);
!       else if (GET_CODE (op) == PLUS
! 	       || GET_CODE (op) == MULT
! 	       || GET_CODE (op) == MEM)
  	recog_data.operand[i] = walk_alter_subreg (recog_data.operand_loc[i]);
      }
  
    for (i = 0; i < recog_data.n_dups; i++)
      {
!       rtx op = *recog_data.dup_loc[i];
! 
!       if (GET_CODE (op) == SUBREG)
  	*recog_data.dup_loc[i] = alter_subreg (recog_data.dup_loc[i]);
!       else if (GET_CODE (op) == PLUS
! 	       || GET_CODE (op) == MULT
! 	       || GET_CODE (op) == MEM)
  	*recog_data.dup_loc[i] = walk_alter_subreg (recog_data.dup_loc[i]);
      }
  }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]