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]

IA-64 patch for reg-alloc problem


This fixes a bug reported by Andreas Schwab on one of the Trillian mailing
lists.  If you had a function that ended up using all local registers, and
the function needed a frame pointer, then we would accidentally use one
local register (loc79) for two different purposes, causing the program to fail
at run-time.

This was tested with an ia64-linux make bootstrap and make check on the gcc-3
branch.  I've added the patch to both the branch and the trunk.

2001-03-13  Jim Wilson  <wilson@redhat.com>

	* config/ia64/ia64.c (find_gr_spill): Subtract frame_pointer_needed
	from 80 in try_locals code.
	(ia64_expand_prologue): Add comment pointing to find_gr_spill change.

Index: ia64.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/ia64/ia64.c,v
retrieving revision 1.75
diff -p -r1.75 ia64.c
*** ia64.c	2001/02/21 21:50:16	1.75
--- ia64.c	2001/03/07 22:38:53
*************** find_gr_spill (try_locals)
*** 1214,1220 ****
    if (try_locals)
      {
        regno = current_frame_info.n_local_regs;
!       if (regno < 80)
  	{
  	  current_frame_info.n_local_regs = regno + 1;
  	  return LOC_REG (0) + regno;
--- 1214,1223 ----
    if (try_locals)
      {
        regno = current_frame_info.n_local_regs;
!       /* If there is a frame pointer, then we can't use loc79, because
! 	 that is HARD_FRAME_POINTER_REGNUM.  In particular, see the
! 	 reg_name switching code in ia64_expand_prologue.  */
!       if (regno < (80 - frame_pointer_needed))
  	{
  	  current_frame_info.n_local_regs = regno + 1;
  	  return LOC_REG (0) + regno;
*************** ia64_expand_prologue ()
*** 1874,1879 ****
--- 1877,1886 ----
    /* Set the frame pointer register name.  The regnum is logically loc79,
       but of course we'll not have allocated that many locals.  Rather than
       worrying about renumbering the existing rtxs, we adjust the name.  */
+   /* ??? This code means that we can never use one local register when
+      there is a frame pointer.  loc79 gets wasted in this case, as it is
+      renamed to a register that will never be used.  See also the try_locals
+      code in find_gr_spill.  */
    if (current_frame_info.reg_fp)
      {
        const char *tmp = reg_names[HARD_FRAME_POINTER_REGNUM];


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