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: john at feith dot com (John Wehle)
- Subject: Re: i386 PIC improvement for static functions.
- From: Jeffrey A Law <law at cygnus dot com>
- Date: Thu, 25 Jun 1998 00:53:11 -0600
- cc: egcs-patches at cygnus dot com, wilson at cygnus dot com, rth at cygnus dot com
- Reply-To: law at cygnus dot com
In message <199806202256.SAA05427@jwlab.FEITH.COM>you write:
> This patch allows the compiler to detect situations which don't require
> the pic register to be loaded for static functions. It works by having
> expand_expr mark functions whose address has been used. Static functions
> which have not been marked by expand_expr don't need to load the pic
> register since they are only called by other functions which are in the
> same file (and hence share the same global table pointer).
>
> ChangeLog:
>
> Sat Jun 20 16:18:00 EDT 1998 John Wehle (john@feith.com)
>
> * toplev.c (rest_of_compilation): Defer static functions
> when optimizing for PIC.
> * tree.h (struct tree_common): Add address_load_flag.
> (TREE_ADDRESS_LOAD): New macro.
> * print-tree.c (print_node): Handle TREE_ADDRESS_LOAD.
> * expr.c (expand_expr): Set TREE_ADDRESS_LOAD if it's a function.
> * i386.c (need_to_load_pic_register): New function.
> (asm_output_function_prefix, ix86_prologue,
> ix86_can_use_return_insn_p, ix86_epilogue): Use it.
This is a very interesting idea. I'd like to get opinions from some
other folks on it though.
My first concern is memory usage; this patch has the potential to
significantly increase the amount of memory necessary to compile a
file since all static functions would be deferred.
If we decide that's not a major problem we might consider deferring
statics regardless of flag_pic. Other architectures do similar
optimizations regardless of -fpic (alpha & rs6000 come immediately to
mind, the PA should, but doesn't due to a lack of time).
I'm also not sure you need a new tree flag -- I think TREE_ADDRESSABLE
does what you want.
jeff