gcc

~vcs-imports/gcc/+git/gcc:hjl/got/gcc-5-branch

Last commit made on 2015-09-27
Get this branch:
git clone -b hjl/got/gcc-5-branch https://git.launchpad.net/~vcs-imports/gcc/+git/gcc

Branch merges

Branch information

Name:
hjl/got/gcc-5-branch
Repository:
lp:~vcs-imports/gcc/+git/gcc

Recent commits

fb814f7... by "H.J. Lu" <email address hidden>

Load address of external function from its GOT slot

Load address of external function from its GOT slot for -fno-plt -fno-pic
if assembler and linker support R_386_GOT32X and R_X86_64_GOTPCRELX to
avoid the PLT slot. R_386_GOT32X and R_X86_64_GOTPCRELX instruct linker
to re-encode the instruction to convert loading function address from its
GOT slot to immediate if the function is defined locally.

gcc/

 PR target/67400
 * config/i386/i386.md (*cmp<mode>_1): Replace
 nonimmediate_operand with ix86_cmp_destination_operand.
 * config/i386/predicates.md (got_slot_operand): New.
 (ix86_cmp_destination_operand): Likewise.
 (x86_64_immediate_operand): Return false if got_slot_operand
 returns true.
 (x86_64_general_operand): Likewise.

gcc/testsuite/

 PR target/67400
 * gcc.target/i386/pr67400-7.c: New test.

fd31e41... by "H.J. Lu" <email address hidden>

Put local/global relocs in rw section for -freloc-rw

Add an option, -freloc-rw, to put local and global relocations in a
read-write section.

gcc/

 PR target/67400
 * common.opt (freloc-rw): New option.
 * targhooks.c (default_reloc_rw_mask): Return 3 for -freloc-rw.

gcc/testsuite/

 PR target/67400
 * gcc.target/i386/pr67400-5.c: New test.
 * gcc.target/i386/pr67400-6.c: Likewise.

0a171f3... by "H.J. Lu" <email address hidden>

Backport struct string_hash from trunk

Backport struct string_hash from trunk for noplt-symbols.c.

 * noplt-symbols.c: Include "vec.h", "double-int.h", "alias.h",
 "symtab.h", "inchash.h" and "hash-set.h".
 * noplt-symbols.h (string_hash): New class.
 (noplt_symbol_table_type): Replace nofree_string_hash with
 string_hash.

5f02da1... by "H.J. Lu" <email address hidden>

Load specific external function addresses via GOT slot

Add -fno-plt=file and -fno-plt=[symbol,...] options to specify which
external function addresses should be loaded from the GOT slot to avoid
PLT. We don't set REG_EQUAL note with external function symbols whose
address are loaded from GOT slots.

gcc/

 PR target/67400
 * Makefile.in (OBJS): Add noplt-symbols.o.
 * common.opt (fno-plt=): New option.
 * explow.c (force_reg): Don't set REG_EQUAL if
 targetm.cannot_set_reg_equal_const returns true.
 * expr.c (emit_move_insn): Likewise.
 * noplt-symbols.c: New file.
 * noplt-symbols.h: Likewise.
 * target.def (cannot_set_reg_equal_const): New target hook.
 * toplev.c: Include "noplt-symbols.h".
 (process_options): Call noplt_symbols_initialize.
 (toplev::main): Call noplt_symbols_finish.
 * config/i386/i386-protos.h (ix86_noplt_operand): New.
 (ix86_noplt_addr_symbol_rtx): Likewise.
 * config/i386/i386.c: Include "noplt-symbols.h".
 (ix86_noplt_rtx_p): New function.
 (ix86_noplt_operand): Likewise.
 (ix86_noplt_addr_symbol_rtx): Likewise.
 (ix86_cannot_set_reg_equal_const): Likewise.
 (ix86_function_ok_for_sibcall): Replace flag_plt with
 !noplt_decl_p.
 (ix86_legitimate_address_p): Allow UNSPEC_GOT and UNSPEC_GOTPCREL
 if ix86_noplt_addr_symbol_rtx doesn't return NULL.
 (ix86_print_operand_address): Support UNSPEC_GOT and
 UNSPEC_GOTPCREL if ix86_noplt_addr_symbol_rtx doesn't return
 NULL.
 (ix86_expand_move): Load the external function address via the
 GOT slot if ix86_noplt_operand returns true.
 (ix86_expand_call): Replace flag_plt and noplt attribute check
 with !ix86_noplt_rtx_p.
 (ix86_nopic_noplt_attribute_p): Call ix86_noplt_rtx_p.
 (TARGET_CANNOT_SET_REG_EQUAL_CONST): New.
 * config/i386/i386.h (SYMBOL_FLAG_PLT): New.
 (SYMBOL_REF_PLT_P): Likewise.
 (SYMBOL_FLAG_NOPLT): Likewise.
 (SYMBOL_REF_NOPLT_P): Likewise.
 * doc/tm.texi.in (TARGET_CANNOT_SET_REG_EQUAL_CONST): New hook.
 * doc/tm.texi: Updated.

gcc/testsuite/

 PR target/67400
 * gcc.target/i386/noplt-5.c: New test.
 * gcc.target/i386/noplt-6.c: Likweise.
 * gcc.target/i386/noplt-7.c: Likweise.
 * gcc.target/i386/noplt-8.c: Likweise.
 * gcc.target/i386/noplt-9.c: Likweise.
 * gcc.target/i386/noplt-10.c: Likweise.
 * gcc.target/i386/noplt-11.c: Likweise.
 * gcc.target/i386/noplt-12.c: Likweise.
 * gcc.target/i386/noplt-13.c: Likweise.
 * gcc.target/i386/noplt-14.c: Likweise.
 * gcc.target/i386/noplt-15.c: Likweise.
 * gcc.target/i386/noplt-16.c: Likweise.
 * gcc.target/i386/noplt-17.c: Likweise.
 * gcc.target/i386/noplt-18.c: Likweise.
 * gcc.target/i386/pr67400-1.c: Likweise.
 * gcc.target/i386/pr67400-2.c: Likewise.
 * gcc.target/i386/pr67400-3.c: Likewise.
 * gcc.target/i386/pr67400-4.c: Likewise.

365de71... by "H.J. Lu" <email address hidden>

Generate R_386_GOT32x relocation for -fno-plt -fno-pic

This patch extends -fno-plt to non-PIC on x86. -fno-plt works in 64-bit
mode with the existing binutils. For 32-bit, we need the updated
assembler and linker to support "call/jmp *foo@GOT", which accesses the
GOT slot without a base register, with a new R_386_GOT32x relocation.

gcc/

 * config/i386/i386.c (ix86_nopic_noplt_attribute_p): Check
 HAVE_LD_R_386_GOT32X == 0 before returning false.
 (ix86_output_call_insn): Generate "%!jmp/call\t*%p0@GOT" for
 32-bit.

gcc/testsuite/

 * gcc.target/i386/pr66232-10.c: New file.
 * gcc.target/i386/pr66232-11.c: Likewise.
 * gcc.target/i386/pr66232-12.c: Likewise.
 * gcc.target/i386/pr66232-13.c: Likewise.
 * lib/target-supports.exp (check_effective_target_r_386_got32x):
 New.
 (check_effective_target_r_x86_64_gotpcrelx): Likewise.

408af40... by "H.J. Lu" <email address hidden>

Check if x86 binutils supports R_386_GOT32X/R_X86_64_GOTPCRELX

Define HAVE_LD_R_386_GOT32X to 1 if 32-bit x86 assembler generates
R_386_GOT32X for "jmp *foo@GOT". Define HAVE_LD_R_X86_64_GOTPCRELX
to 1 if 64-bit x86 assembler generates R_X86_64_GOTPCRELX for
"jmp *foo@GOTPCREL(%rip)".

 * configure.ac (HAVE_LD_R_386_GOT32X): New. Defined to 1
 if 32-bit assembler generates R_386_GOT32X for "jmp *foo@GOT".
 Otherise, defined to 0.
 (HAVE_LD_R_X86_64_GOTPCRELX): New. Defined to 1 if 64-bit
 x86 assembler generates R_X86_64_GOTPCRELX for
 "jmp *foo@GOTPCREL(%rip)".
 * config.in: Regenerated.
 * configure: Likewise.

6b8257b... by "H.J. Lu" <email address hidden>

Check $READELF_FOR_TARGET for readelf in configure

Similar to as, ld, nm and objdump, gcc configure should check
$READELF_FOR_TARGET for readelf.

 PR bootstrap/67385
 * configure.ac (gcc_cv_readelf): Check $READELF_FOR_TARGET.
 * configure: Regenerated.

9c6d1c9... by "H.J. Lu" <email address hidden>

Properly handle -fno-plt in ix86_expand_call

prepare_call_address in calls.c is the wrong place to handle -fno-plt.
We shoudn't force function address into register and hope that load
function address via GOT and indirect call via register will be folded
into indirect call via GOT, which doesn't always happen. Also non-PIC
case can only be handled in backend. Instead, backend should expand
external function call into indirect call via GOT for -fno-plt.

This patch reverts -fno-plt in prepare_call_address and handles it in
ix86_expand_call. Other backends may need similar changes to support
-fno-plt. Alternately, we can introduce a target hook to indicate
whether an external function should be called via register for -fno-plt
so that i386 backend can disable it in prepare_call_address.

gcc/

 PR target/67215
 * calls.c (prepare_call_address): Don't handle -fno-plt here.
 * config/i386/i386.c (ix86_expand_call): Generate indirect call
 via GOT for -fno-plt. Support indirect call via GOT for x32.
 * config/i386/predicates.md (sibcall_memory_operand): Allow
 GOT memory operand.

gcc/testsuite/

 PR target/67215
 * gcc.target/i386/pr67215-1.c: New test.
 * gcc.target/i386/pr67215-2.c: Likewise.
 * gcc.target/i386/pr67215-3.c: Likewise.

7e02b63... by hjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>

Add more tests for PR target/66232

 PR target/66232
 * gcc.target/i386/pr66232-6.c: New tests.
 * gcc.target/i386/pr66232-7.c: Likewise.
 * gcc.target/i386/pr66232-8.c: Likewise.
 * gcc.target/i386/pr66232-9.c: Likewise.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@226254 138bc75d-0d04-0410-961f-82ee72b054a4

9eb9f04... by hjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>

Allow indirect sibcall with register arguments

Indirect sibcall with register arguments is OK when there is register
available for argument passing.

gcc/

 PR target/66819
 * config/i386/i386.c (ix86_function_ok_for_sibcall): Allow
 indirect sibcall with register arguments if register available
 for argument passing.
 (init_cumulative_args): Set cfun->machine->arg_reg_available
 to (cum->nregs > 0) or to true if function has a variable
 argument list.
 (function_arg_advance_32): Set cfun->machine->arg_reg_available
 to false if cum->nregs <= 0.
 * config/i386/i386.h (machine_function): Add arg_reg_available.

gcc/testsuite/

 PR target/66819
 * gcc.target/i386/pr66819-1.c: New test.
 * gcc.target/i386/pr66819-2.c: Likewise.
 * gcc.target/i386/pr66819-3.c: Likewise.
 * gcc.target/i386/pr66819-4.c: Likewise.
 * gcc.target/i386/pr66819-5.c: Likewise.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@225688 138bc75d-0d04-0410-961f-82ee72b054a4