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]

Re: [m68k] register renaming not properly tracking used registers


>On Sun, Oct 17, 2004 at 04:32:26PM -0400, Peter Barada wrote:
>> Where in the code should I look to track this problem down?
>
>You should use HARD_REGNO_RENAME_OK to disallow using non-live
>registers in interrupt functions.

Ok, here's a patch to fix it on gcc-3.4.1 and gcc-3.4.2.  The original
problem doesn't show on uberbaum.

Tested on gcc-3.4.1, gcc-3.4.2; built on uberbaum.

gcc/ChangeLog:
2004-09-103  Peter Barada <peter@the-baradas.com>
	* config/m68k/m68k.h (HARD_REGNO_RENAME_OK): New macro.
	* config/m68k/m68k.c (m68k_hard regno_rename_ok): Disallow
	  renaming of non-live registers in interrupt functions.
	* config/m68k/m68k-protos.h (m68k_hard_regno_rename_ok): Add prototype.


Index: m68k-protos.h
===================================================================
RCS file: /cvs/uberbaum/gcc/config/m68k/m68k-protos.h,v
retrieving revision 1.16
diff -c -3 -p -r1.16 m68k-protos.h
*** m68k-protos.h	24 Jul 2004 11:12:29 -0000	1.16
--- m68k-protos.h	20 Oct 2004 23:33:08 -0000
*************** extern void print_operand_address (FILE 
*** 50,55 ****
--- 50,57 ----
  extern void print_operand (FILE *, rtx, int);
  extern void notice_update_cc (rtx, rtx);
  extern rtx legitimize_pic_address (rtx, enum machine_mode, rtx);
+ extern int m68k_hard_regno_rename_ok(unsigned int, unsigned int);
+ 
  #endif /* RTX_CODE */
  
  extern int flags_in_68881 (void);
Index: m68k.c
===================================================================
RCS file: /cvs/uberbaum/gcc/config/m68k/m68k.c,v
retrieving revision 1.141
diff -c -3 -p -r1.141 m68k.c
*** m68k.c	18 Sep 2004 19:19:36 -0000	1.141
--- m68k.c	20 Oct 2004 23:33:09 -0000
*************** m68k_struct_value_rtx (tree fntype ATTRI
*** 3428,3430 ****
--- 3428,3447 ----
  {
    return gen_rtx_REG (Pmode, M68K_STRUCT_VALUE_REGNUM);
  }
+ 
+ /* Return nonzero if register old_reg can be renamed to register new_reg.  */
+ int
+ m68k_hard_regno_rename_ok (unsigned int old_reg ATTRIBUTE_UNUSED,
+ 			   unsigned int new_reg)
+ {
+ 
+ /* Interrupt functions can only use registers that have already been
+    saved by the prologue, even if they would normally be
+    call-clobbered.  */
+ 
+   if (m68k_interrupt_function_p(current_function_decl)
+       && !regs_ever_live[new_reg])
+      return 0;
+ 
+    return 1;
+ }
Index: m68k.h
===================================================================
RCS file: /cvs/uberbaum/gcc/config/m68k/m68k.h,v
retrieving revision 1.120
diff -c -3 -p -r1.120 m68k.h
*** m68k.h	6 Aug 2004 07:14:56 -0000	1.120
--- m68k.h	20 Oct 2004 23:33:09 -0000
*************** extern int target_flags;
*** 480,485 ****
--- 480,491 ----
    ((REGNO) >= 16 ? GET_MODE_NUNITS (MODE)	\
     : ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD))
  
+ /* A C expression that is nonzero if hard register NEW_REG can be
+    considered for use as a rename register for OLD_REG register.  */
+ 
+ #define HARD_REGNO_RENAME_OK(OLD_REG, NEW_REG) \
+    m68k_hard_regno_rename_ok (OLD_REG, NEW_REG)
+ 
  /* On the m68k, the cpu registers can hold any mode but the 68881 registers
     can hold only SFmode or DFmode.  */
  #define HARD_REGNO_MODE_OK(REGNO, MODE) \


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