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]

patch to omit the frame pointer from leaf functions (version 2)


This patch follows Intel's recommendation of omitting the frame
pointer when optimizing functions where the stack is unchanging.

Issues:

  1) Both m88k and i386 ports use TARGET_OMIT_LEAF_FRAME_POINTER
     to set flag_omit_frame_pointer in OVERRIDE_OPTIONS.  The
     name of the macro suggest that the frame pointer is only
     to be omitted for leaf functions, yet I'm under the impression
     that flag_omit_frame_pointer will attempt to omit the frame
     pointer from all functions.  I suspect that this code should
     just be deleted.

     In addition, the m88k defines CAN_DEBUG_WITHOUT_FP which
     causes flag_omit_frame_pointer to always be set when -O
     is specified.  Is this desirable given that fact that the
     m88k port also uses TARGET_OMIT_LEAF_FRAME_POINTER?

  2) The i386 port uses flag_omit_frame_pointer in
     CONST_DOUBLE_OK_FOR_LETTER_P.  I'm unclear about the issues
     involved.

  3) Debugging.  Couple of thoughts:

     a) Update egcs and gdb to use DWARF2 to support debugging
        code which has been optimized by this patch.  I'm under
        the impression that egcs already outputs the correct
        information and that it's just a matter of updating gdb.
        I'm not sure about the scope of the work involved.

     b) Just update gdb to handle i386 code which has been
        optimized in this fashion.  It's not clear to me how
        gdb can tell the difference between a frameless function
        with an unchanging stack pointer and a frameless function
        with a changing stack pointer.

     What targets (other the i386) are unabled to debug code
     which has been optimized by this patch?

ChangeLog:

Sat Oct 17 00:26:21 EDT 1998  John Wehle  (john@feith.com)

	* reload1.c (init_elim_table): Don't set frame_pointer_needed when
	optimizing functions where the stack pointer is unchanging.
	* i386.c (i386_aligned_reg_p): Realize that the frame pointer is
	also eliminated if current_function_sp_is_unchanging is set.
	* pa.c (basereg_operand): Likewise.

Enjoy!

-- John Wehle
------------------8<------------------------8<------------------------
*** gcc/reload1.c.ORIGINAL	Fri Oct 16 23:30:15 1998
--- gcc/reload1.c	Sat Oct 17 00:21:29 1998
*************** init_elim_table ()
*** 3877,3883 ****
  
    /* Does this function require a frame pointer?  */
  
!   frame_pointer_needed = (! flag_omit_frame_pointer
  #ifdef EXIT_IGNORE_STACK
  			  /* ?? If EXIT_IGNORE_STACK is set, we will not save
  			     and restore sp for alloca.  So we can't eliminate
--- 3877,3884 ----
  
    /* Does this function require a frame pointer?  */
  
!   frame_pointer_needed = (! (flag_omit_frame_pointer
! 			     || current_function_sp_is_unchanging)
  #ifdef EXIT_IGNORE_STACK
  			  /* ?? If EXIT_IGNORE_STACK is set, we will not save
  			     and restore sp for alloca.  So we can't eliminate
*** gcc/config/i386/i386.c.ORIGINAL	Tue Oct 13 10:14:44 1998
--- gcc/config/i386/i386.c	Sat Oct 17 01:07:23 1998
*************** i386_aligned_reg_p (regno)
*** 492,498 ****
       int regno;
  {
    return (regno == STACK_POINTER_REGNUM
! 	  || (! flag_omit_frame_pointer && regno == FRAME_POINTER_REGNUM));
  }
  
  int
--- 492,499 ----
       int regno;
  {
    return (regno == STACK_POINTER_REGNUM
! 	  || (! (flag_omit_frame_pointer || current_function_sp_is_unchanging)
! 	      && regno == FRAME_POINTER_REGNUM));
  }
  
  int
*** gcc/config/pa/pa.c.ORIGINAL	Sun Oct 11 13:57:29 1998
--- gcc/config/pa/pa.c	Sat Oct 17 01:05:22 1998
*************** basereg_operand (op, mode)
*** 5710,5716 ****
    /* While it's always safe to index off the frame pointer, it's not
       always profitable, particularly when the frame pointer is being
       eliminated.  */
!   if (! flag_omit_frame_pointer && op == frame_pointer_rtx)
      return 1;
  
    /* The only other valid OPs are pseudo registers with
--- 5710,5717 ----
    /* While it's always safe to index off the frame pointer, it's not
       always profitable, particularly when the frame pointer is being
       eliminated.  */
!   if (! (flag_omit_frame_pointer || current_function_sp_is_unchanging)
!       && op == frame_pointer_rtx)
      return 1;
  
    /* The only other valid OPs are pseudo registers with
-------------------------------------------------------------------------
|   Feith Systems  |   Voice: 1-215-646-8000  |  Email: john@feith.com  |
|    John Wehle    |     Fax: 1-215-540-5495  |                         |
-------------------------------------------------------------------------



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