Add TARGET_IFUNC_REF_LOCAL_OK
authorH.J. Lu <hjl.tools@gmail.com>
Sat, 19 Jun 2021 15:16:45 +0000 (08:16 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Fri, 3 Dec 2021 13:12:30 +0000 (05:12 -0800)
commitf7854b908977adce4ff669c4e0332ef868568b7c
treed2f77c87c4dd0166bbb3f636f2d7d717a26eed12
parent97ffef3553267f52ca83dbebdcc8b5e3739febee
Add TARGET_IFUNC_REF_LOCAL_OK

1. On some targets, like PowerPC, reference to ifunc function resolver
must be non-local so that compiler will properly emit PLT call.  Add
TARGET_IFUNC_REF_LOCAL_OK to allow binding indirect function resolver
locally for targets which don't require special PLT call sequence.
2. Add ix86_call_use_plt_p to call local ifunc function resolvers via
PLT.

gcc/

PR target/51469
PR target/83782
* target.def (ifunc_ref_local_ok): Add a target hook.
* varasm.c (default_binds_local_p_3): Force indirect function
resolver non-local only if targetm.ifunc_ref_local_ok returns
false.
* config/i386/i386-expand.c (ix86_expand_call): Call
ix86_call_use_plt_p to check if PLT should be used.
* config/i386/i386-protos.h (ix86_call_use_plt_p): New.
* config/i386/i386.c (output_pic_addr_const): Call
ix86_call_use_plt_p to check if "@PLT" is needed.
(ix86_call_use_plt_p): New.
(TARGET_IFUNC_REF_LOCAL_OK): New.
* doc/tm.texi.in: Add TARGET_IFUNC_REF_LOCAL_OK.
* doc/tm.texi: Regenerated.

gcc/testsuite/

PR target/51469
PR target/83782
* gcc.target/i386/pr83782-1.c: New test.
* gcc.target/i386/pr83782-2.c: Likewise.
gcc/config/i386/i386-expand.c
gcc/config/i386/i386-protos.h
gcc/config/i386/i386.c
gcc/doc/tm.texi
gcc/doc/tm.texi.in
gcc/target.def
gcc/testsuite/gcc.target/i386/pr83782-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/pr83782-2.c [new file with mode: 0644]
gcc/varasm.c