From b6d10e0b06b82a100a695ae13659c71be34bb032 Mon Sep 17 00:00:00 2001 From: Kaz Kojima Date: Wed, 24 Jun 2015 22:11:04 +0000 Subject: [PATCH] re PR target/66563 (ICE (segmentation fault) on sh4-linux-gnu) PR target/66563 * [SH] Add a new operand to GOTaddr2picreg so to avoid CSE. Modify caller of gen_GOTaddr2picreg. From-SVN: r224925 --- gcc/ChangeLog | 11 +++++++++++ gcc/config/sh/sh.c | 5 +++-- gcc/config/sh/sh.md | 32 +++++++++++++++++++------------- 3 files changed, 33 insertions(+), 15 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 944e89c5fa5..550f7888b2a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +2015-06-24 Kaz Kojima + + PR target/66563 + * config/sh/sh.md (GOTaddr2picreg): Add a new operand for + an additional element of the unspec vector. Modify indices + of operands. + (builtin_setjmp_receiver): Pass const0_rtx to gen_GOTaddr2picreg. + * config/sh/sh.c (prepare_move_operands): Pass incremented + const_int to gen_GOTaddr2picreg. + (sh_expand_prologue): Pass const0_rtx to gen_GOTaddr2picreg. + 2015-06-24 Alan Lawrence * config/aarch64/aarch64.md (2): diff --git a/gcc/config/sh/sh.c b/gcc/config/sh/sh.c index 6f03206ccb9..2c247b1af14 100644 --- a/gcc/config/sh/sh.c +++ b/gcc/config/sh/sh.c @@ -1845,12 +1845,13 @@ prepare_move_operands (rtx operands[], machine_mode mode) || tls_kind == TLS_MODEL_LOCAL_DYNAMIC || tls_kind == TLS_MODEL_INITIAL_EXEC)) { + static int got_labelno; /* Don't schedule insns for getting GOT address when the first scheduling is enabled, to avoid spill failures for R0. */ if (flag_schedule_insns) emit_insn (gen_blockage ()); - emit_insn (gen_GOTaddr2picreg ()); + emit_insn (gen_GOTaddr2picreg (GEN_INT (++got_labelno))); emit_use (gen_rtx_REG (SImode, PIC_REG)); if (flag_schedule_insns) emit_insn (gen_blockage ()); @@ -7958,7 +7959,7 @@ sh_expand_prologue (void) } if (flag_pic && df_regs_ever_live_p (PIC_OFFSET_TABLE_REGNUM)) - emit_insn (gen_GOTaddr2picreg ()); + emit_insn (gen_GOTaddr2picreg (const0_rtx)); if (SHMEDIA_REGS_STACK_ADJUST ()) { diff --git a/gcc/config/sh/sh.md b/gcc/config/sh/sh.md index e88d249ef41..43cd949d2d0 100644 --- a/gcc/config/sh/sh.md +++ b/gcc/config/sh/sh.md @@ -10592,12 +10592,18 @@ label: [(set_attr "in_delay_slot" "no") (set_attr "type" "arith")]) +;; Loads of the GOTPC relocation values must not be optimized away +;; by e.g. any kind of CSE and must stay as they are. Although there +;; are other various ways to ensure this, we use an artificial counter +;; operand to generate unique symbols. (define_expand "GOTaddr2picreg" [(set (reg:SI R0_REG) - (unspec:SI [(const:SI (unspec:SI [(match_dup 1)] UNSPEC_PIC))] - UNSPEC_MOVA)) - (set (match_dup 0) (const:SI (unspec:SI [(match_dup 1)] UNSPEC_PIC))) - (set (match_dup 0) (plus:SI (match_dup 0) (reg:SI R0_REG)))] + (unspec:SI [(const:SI (unspec:SI [(match_dup 2) + (match_operand:SI 0 "" "")] + UNSPEC_PIC))] UNSPEC_MOVA)) + (set (match_dup 1) + (const:SI (unspec:SI [(match_dup 2) (match_dup 0)] UNSPEC_PIC))) + (set (match_dup 1) (plus:SI (match_dup 1) (reg:SI R0_REG)))] "" { if (TARGET_VXWORKS_RTP) @@ -10608,8 +10614,8 @@ label: DONE; } - operands[0] = gen_rtx_REG (Pmode, PIC_REG); - operands[1] = gen_rtx_SYMBOL_REF (VOIDmode, GOT_SYMBOL_NAME); + operands[1] = gen_rtx_REG (Pmode, PIC_REG); + operands[2] = gen_rtx_SYMBOL_REF (VOIDmode, GOT_SYMBOL_NAME); if (TARGET_SHMEDIA) { @@ -10618,23 +10624,23 @@ label: rtx lab = PATTERN (gen_call_site ()); rtx insn, equiv; - equiv = operands[1]; - operands[1] = gen_rtx_UNSPEC (Pmode, gen_rtvec (2, operands[1], lab), + equiv = operands[2]; + operands[2] = gen_rtx_UNSPEC (Pmode, gen_rtvec (2, operands[2], lab), UNSPEC_PCREL_SYMOFF); - operands[1] = gen_rtx_CONST (Pmode, operands[1]); + operands[2] = gen_rtx_CONST (Pmode, operands[2]); if (Pmode == SImode) { - emit_insn (gen_movsi_const (pic, operands[1])); + emit_insn (gen_movsi_const (pic, operands[2])); emit_insn (gen_ptrel_si (tr, pic, copy_rtx (lab))); } else { - emit_insn (gen_movdi_const (pic, operands[1])); + emit_insn (gen_movdi_const (pic, operands[2])); emit_insn (gen_ptrel_di (tr, pic, copy_rtx (lab))); } - insn = emit_move_insn (operands[0], tr); + insn = emit_move_insn (operands[1], tr); set_unique_reg_note (insn, REG_EQUAL, equiv); @@ -10688,7 +10694,7 @@ label: [(match_operand 0 "" "")] "flag_pic" { - emit_insn (gen_GOTaddr2picreg ()); + emit_insn (gen_GOTaddr2picreg (const0_rtx)); DONE; }) -- 2.30.2