This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: RFA/C: Lazily-bound GOT entries
- From: Ian Lance Taylor <iant at google dot com>
- To: Richard Sandiford <rsandifo at nildram dot co dot uk>
- Cc: gcc-patches at gcc dot gnu dot org, Richard Guenther <rguenther at suse dot de>
- Date: 23 Jan 2008 10:38:54 -0800
- Subject: Re: RFA/C: Lazily-bound GOT entries
- References: <87abnd3jv6.fsf@firetop.home>
Richard Sandiford <rsandifo@nildram.co.uk> writes:
> gcc/
> * doc/tm.texi: Document GOT_VERSION_REGNUM.
> * doc/md.texi: Document update_got_version.
> * defaults.h (GOT_VERSION_REGNUM): Define.
> * expr.h (emit_update_got_version): Declare.
> * builtins.c (expand_builtin_apply): Call emit_update_got_version.
> * calls.c (expand_call, expand_library_call_value_1): Likewise.
> (emit_update_got_version): New function.
> * df-scan.c (df_bb_refs_collect): Only compute bb_has_eh_pred once.
> Add artificial definitions of GOT_VERSION_REGNUM for exception
> handlers and nonlocal-goto receivers.
> (df_get_entry_block_def_set): Include GOT_VERSION_REGNUM.
> (df_get_exit_block_use_set): Likewise.
> * gcse.c (compute_hash_table_work): Record artificial definitions
> at the top of the block.
>
> * config/mips/mips.h (FIRST_PSEUDO_REGISTER): Update comment
> after renaming FAKE_CALL_REGNO to C_GOT_VERSION_REGNUM.
> (CALL_REALLY_USED_REGISTERS): Set the C_GOT_VERSION_REGNUM entry to 0.
> (GOT_VERSION_REGNUM): Define.
> * config/mips/mips.c (mips_expand_call): Don't use FAKE_CALL_REGNO.
> (mips_hard_regno_mode_ok_p): Allow SImode for C_GOT_VERSION_REGNUM.
> (mips_avoid_hazard): Remove hazard_set handling.
> * config/mips/mips.md (UNSPEC_UPDATE_GOT_VERSION): New constant.
> (FAKE_CALL_REGNO): Rename to...
> (C_GOT_VERSION_REGNUM): ...this.
> (type): Add "ghost". Add an insn_reservation for it.
> (hazard_set): Delete.
> (load_call<mode>): Don't set FAKE_CALL_REGNUM; use
> C_GOT_VERSION_REGNUM instead. Remove hazard_set attribute.
> (update_got_version): New instruction.
I apologize for not looking at this earlier.
It seems to me that the problem here can only arise for target for
which the PIC call sequence involves loading the call target into a
register. That is uncommon.
I don't see any need for the middle-end to explicitly call
emit_update_got_version. Since that will always be completely target
specific, it seems to me that the backend can generate it along with
the call instruction, in a define_expand.
Also, it seems to me that in general we should only worry about this
when compiling with -fpic. I think that would be consistent with our
other special treatment of function calls when -fpic is used. Of
course on the MIPS port -fpic is essentially the default.
You can already express a dependency between call instructions in the
backend. So what you need is a way to express a dependency between
call instructions and exception blocks. In other words, I think that
all you really need is your patches to df-scan.c and gcse.c. I know
you were aiming at making this work more target independent, but 1) it
doesn't seem all that target independent anyhow, and 2) very few
targets need this.
In df-scan.c you want a way to say "this register is set at function
entry, is referenced at an exception block or the target of a
non-local goto, and is referenced at function exit." Basically, it's
a global register. How would you feel about a patch along those
lines?
The patch to gcse.c seems more-or-less independent; it looks right to
me, but ask a DF maintainer.
Ian