This is the mail archive of the
mailing list for the GCC project.
Re: How do I delete redundant prologue/epilogue instructions?
- From: James E Wilson <wilson at specifix dot com>
- To: Daniel Towner <daniel dot towner at picochip dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Wed, 17 Aug 2005 12:12:48 -0700
- Subject: Re: How do I delete redundant prologue/epilogue instructions?
- References: <430201AC.email@example.com>
Daniel Towner wrote:
> register renaming is able to change the registers used by the function
> from callee-save to caller-save, removing any need for the
> save/restore/stack adjust code in the prologue/epilogue. However, the
> instructions which perform these operations are still emitted.
I doubt that any port does this optimization. You would have to redo
the bulk of reload: register elimination, assigning stack slot
addresses, recomputing frame size and register save offsets, etc. Gcc
isn't set up to do this.
In the simplest case, if you have no locals, no frame pointer, no
alloca, no outgoing args on the stack, etc, then a simple RTL scan of
the function may prove that SP/FP/AP are never used, allowing us to
remove code in the prologue and epilogue. However, I'm skeptical that
this would occur often enough to be useful. And it would require some
target dependent code to figure out how to do the rewrites, which may
make this complicated.
It is probably easier to try to avoid this situation, by getting better
register allocation earlier. Make sure that the caller-save registers
occur before the callee-save registers in REG_ALLOC_ORDER. Verify that
the caller-save.c code which is used in reload is working for your
target. We could try moving some of the regrename optimizations to
Jim Wilson, GNU Tools Support, http://www.specifix.com