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]

[PATCH] PR 23473 Fix fallout from patch for PR 23355


A consequence of my patch for PR 23355 is that we now have to be more
careful about when we call thumb_find_work_register, because if we
aren't saving the pic register there may not be a scratch available. 
This wouldn't have mattered (since we never used the scratch when we
didn't need the pic register) but for the fact that
thumb_find_work_register would abort if a scratch wasn't available.

Fixed with:

2005-08-19  Richard Earnshaw  <richard.earnshaw@arm.com>

	PR target/23473
	* arm.md (arm_load_pic_register): Change argument to the mask of
	saved registers.  Call thumb_find_work_register if we need a 
	scratch register on Thumb.
	(arm_expand_prologue): Pass empty register set to 
	arm_load_pic_register.
	(thumb_expand_prologue): Pass live_regs_mask directly to
	arm_load_pic_register.
	* arm-protos.h (arm_load_pic_register): Update prototype.

Tested on arm-elf and with additional pic test cases.


Index: arm.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/arm/arm.c,v
retrieving revision 1.474
diff -p -r1.474 arm.c
*** arm.c	19 Aug 2005 09:20:25 -0000	1.474
--- arm.c	19 Aug 2005 13:09:49 -0000
*************** thumb_find_work_register (unsigned long 
*** 3285,3291 ****
     low register.  */
  
  void
! arm_load_pic_register (unsigned int scratch)
  {
  #ifndef AOF_ASSEMBLER
    rtx l1, pic_tmp, pic_tmp2, pic_rtx;
--- 3285,3291 ----
     low register.  */
  
  void
! arm_load_pic_register (unsigned long saved_regs ATTRIBUTE_UNUSED)
  {
  #ifndef AOF_ASSEMBLER
    rtx l1, pic_tmp, pic_tmp2, pic_rtx;
*************** arm_load_pic_register (unsigned int scra
*** 3319,3327 ****
      {
        if (REGNO (pic_offset_table_rtx) > LAST_LO_REGNUM)
  	{
! 	  /* We will have pushed the pic register, so should always be
  	     able to find a work register.  */
! 	  pic_tmp = gen_rtx_REG (SImode, scratch);
  	  emit_insn (gen_pic_load_addr_thumb (pic_tmp, pic_rtx));
  	  emit_insn (gen_movsi (pic_offset_table_rtx, pic_tmp));
  	}
--- 3319,3328 ----
      {
        if (REGNO (pic_offset_table_rtx) > LAST_LO_REGNUM)
  	{
! 	  /* We will have pushed the pic register, so we should always be
  	     able to find a work register.  */
! 	  pic_tmp = gen_rtx_REG (SImode,
! 				 thumb_find_work_register (saved_regs));
  	  emit_insn (gen_pic_load_addr_thumb (pic_tmp, pic_rtx));
  	  emit_insn (gen_movsi (pic_offset_table_rtx, pic_tmp));
  	}
*************** arm_expand_prologue (void)
*** 10509,10515 ****
  
  
    if (flag_pic)
!     arm_load_pic_register (INVALID_REGNUM);
  
    /* If we are profiling, make sure no instructions are scheduled before
       the call to mcount.  Similarly if the user has requested no
--- 10510,10516 ----
  
  
    if (flag_pic)
!     arm_load_pic_register (0UL);
  
    /* If we are profiling, make sure no instructions are scheduled before
       the call to mcount.  Similarly if the user has requested no
*************** thumb_expand_prologue (void)
*** 13236,13242 ****
    /* Load the pic register before setting the frame pointer,
       so we can use r7 as a temporary work register.  */
    if (flag_pic)
!     arm_load_pic_register (thumb_find_work_register (live_regs_mask));
  
    offsets = arm_get_frame_offsets ();
  
--- 13237,13243 ----
    /* Load the pic register before setting the frame pointer,
       so we can use r7 as a temporary work register.  */
    if (flag_pic)
!     arm_load_pic_register (live_regs_mask);
  
    offsets = arm_get_frame_offsets ();
  
Index: arm-protos.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/arm/arm-protos.h,v
retrieving revision 1.90
diff -p -r1.90 arm-protos.h
*** arm-protos.h	19 Aug 2005 09:20:31 -0000	1.90
--- arm-protos.h	19 Aug 2005 13:09:49 -0000
***************
*** 27,33 ****
  extern void arm_override_options (void);
  extern int use_return_insn (int, rtx);
  extern int arm_regno_class (int);
! extern void arm_load_pic_register (unsigned int);
  extern int arm_volatile_func (void);
  extern const char *arm_output_epilogue (rtx);
  extern void arm_expand_prologue (void);
--- 27,33 ----
  extern void arm_override_options (void);
  extern int use_return_insn (int, rtx);
  extern int arm_regno_class (int);
! extern void arm_load_pic_register (unsigned long);
  extern int arm_volatile_func (void);
  extern const char *arm_output_epilogue (rtx);
  extern void arm_expand_prologue (void);

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