This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: i386 PIC improvement for static functions.
- To: law at cygnus dot com
- Subject: Re: i386 PIC improvement for static functions.
- From: Jim Wilson <wilson at cygnus dot com>
- Date: Fri, 26 Jun 1998 17:59:15 -0700
- cc: john at feith dot com (John Wehle), egcs-patches at cygnus dot com, rth at cygnus dot com
The SGI Irix5 tools perform a similar optimization in the linker.
At that time it is easy to tell whether a function ever has its address taken,
there will be a relocation using it. It is however more difficult to do
the optimization then, as the linker needs to rewrite the code a bit,
and you need to hack the linker instead of hacking the compiler. This
does avoid the memory usage problems though if we try to do this in
gcc.
Alternatively, maybe we can do some kind of two pass compilation. If we
parse the input file (throwing away trees and RTL) just to figure out what
functions have their addresses taken, and then parse it for real a second
time, this avoids needing to keep all of the trees and/or RTL in memory
until the end. This does mean we pay the cost of parsing it twice though.
I think the Chill front end does something like this, because variables can
be used before their types have been declared or something like that.
If we do defer all static functions, I think there will be serious memory
usage problems.
Jim