]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR target/66563 (ICE (segmentation fault) on sh4-linux-gnu)
authorKaz Kojima <kkojima@gcc.gnu.org>
Sun, 28 Jun 2015 07:02:47 +0000 (07:02 +0000)
committerKaz Kojima <kkojima@gcc.gnu.org>
Sun, 28 Jun 2015 07:02:47 +0000 (07:02 +0000)
PR target/66563
* [SH] Add a new operand to GOTaddr2picreg so to avoid CSE.  Modify caller
  of gen_GOTaddr2picreg.

From-SVN: r225104

gcc/ChangeLog
gcc/config/sh/sh.c
gcc/config/sh/sh.md

index 7aacc415b56f40b0a4f6daf2b021825ad78e7481..2eaddf52d75fe35759046c0e0f0912480dc9e195 100644 (file)
@@ -1,3 +1,17 @@
+2015-06-28  Kaz Kojima  <kkojima@gcc.gnu.org>
+
+       Backport from mainline
+       2015-06-24  Kaz Kojima  <kkojima@gcc.gnu.org>
+
+       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-27  Uros Bizjak  <ubizjak@gmail.com>
            Segher Boessenkool  <segher@kernel.crashing.org>
 
index f2474286004ebe68acfb8e99b589e16c474b28f4..a29e1b9cdfccd48598ce5c8304ee1188bb25d8a0 100644 (file)
@@ -1746,12 +1746,13 @@ prepare_move_operands (rtx operands[], enum 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 ());
@@ -7768,7 +7769,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 ())
     {
index a0688e63645978a95b76046f1f625c700985e085..6b1cf12010ed49c6c42e5670fbc52091b86a8db9 100644 (file)
@@ -9999,12 +9999,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)
@@ -10015,8 +10021,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)
     {
@@ -10025,23 +10031,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);
 
@@ -10095,7 +10101,7 @@ label:
   [(match_operand 0 "" "")]
   "flag_pic"
 {
-  emit_insn (gen_GOTaddr2picreg ());
+  emit_insn (gen_GOTaddr2picreg (const0_rtx));
   DONE;
 })