patch to improve i386 epilogue (version 4)

Jeffrey A Law law@cygnus.com
Thu Oct 8 14:09:00 GMT 1998


  In message < 199810081643.MAA13935@jwlab.FEITH.COM >you write:
  > You're right ... it's probably asking for trouble.  What are the issues
  > with modifying lifetime_analysis so that the stack pointer is marked as
  > live at the end of a function which doesn't use alloca and doesn't clobber
  > the stack pointer in any other way?  Any problem with just modifying this
  > patch to mark the stack pointer as live in this situation?
That's a good question.  I've been trying to figure out how I would describe
when we want to do this in a generic manner.

Basically, even though we have a frame pointer that can be used in the epilogue,
there are cases (and the x86 is not unique in this regard) where a more
efficient epilogue can be generated by using the stack pointer instead when
its value is known to be correct.

I guess we could have flow mark the stack pointer as live at the end of the
last block if the target has defined some magic macro like
SP_LIVE_AT_END_OF_LEAF_FUNCTION or something of that nature.

Of course, if we start eliminating frame pointers in leaf functions, then this
becomes a moot point.

  > I belive that Jason mentioned DWARF 2 supports the necessary information
  > to do this.  Do any of the other debugging formats support this?  I'm
  > willing to look at modifying gdb ... any idea of the effort involved?
In a leaf function, the stack pointer should be constant -- thus you shouldn't
need any of the dwarf2 features to track the difference between sp and the
base of the frame.

I believe it's just a matter of hacking up the frame_chain code in the x86
target files to identify a frameless function and set the base of frame to
the value of the stack pointer at entry to a frameless function.

You may also need to come up with a suitable definition of DEBUGGER_ARG_OFFSET
and DEBUGGER_AUTO_OFFSET, but that's usually easy and the code can be cribbed
from other ports like the pa, mn10x00, mips, etc.


The nice thing is once you've hacked up gdb in this manner, you can also do
frame pointer elimination in non-leaf functions if they have no outgoing args
(ie, they make function calls, but don't pass parameters to those functions).
This happens more than I would have ever believed (I did this on the mn10x00
series ports before I finally fixed the problems which prevented them from
defining ACCUMULATE_OUTGOING_ARGS).


jeff



More information about the Gcc-patches mailing list