sh.c (prepare_move_operands): Set pic register appropriately for global and local...
authorKaz Kojima <kkojima@gcc.gnu.org>
Wed, 8 Jun 2011 03:54:05 +0000 (03:54 +0000)
committerKaz Kojima <kkojima@gcc.gnu.org>
Wed, 8 Jun 2011 03:54:05 +0000 (03:54 +0000)
* config/sh/sh.c (prepare_move_operands): Set pic register
appropriately for global and local dynamic tls models even
if flag_pic is unset.

From-SVN: r174792

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

index 6c1a5c2038c5fe34320447f40a8c2076573ec4f6..ff7cd0bbddfce7f45a4c68fd6e5e8a1d3af75fb3 100644 (file)
@@ -1,3 +1,9 @@
+2011-06-08  Kaz Kojima  <kkojima@gcc.gnu.org>
+
+       * config/sh/sh.c (prepare_move_operands): Set pic register
+       appropriately for global and local dynamic tls models even
+       if flag_pic is unset.
+
 2011-06-07  Jason Merrill  <jason@redhat.com>
 
        * pretty-print.h (ATTRIBUTE_GCC_PPDIAG): Use GCC_DIAG_STYLE if set.
index c5fbd569602c323810536a0428a37437543436cd..f81172545a4dd4c0cda911d6b4c70522c8c1a66d 100644 (file)
@@ -1844,12 +1844,30 @@ prepare_move_operands (rtx operands[], enum machine_mode mode)
        {
          rtx tga_op1, tga_ret, tmp, tmp2;
 
+         if (! flag_pic
+             && (tls_kind == TLS_MODEL_GLOBAL_DYNAMIC
+                 || tls_kind == TLS_MODEL_LOCAL_DYNAMIC
+                 || tls_kind == TLS_MODEL_INITIAL_EXEC))
+           {
+             /* 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_use (gen_rtx_REG (SImode, PIC_REG));
+             if (flag_schedule_insns)
+               emit_insn (gen_blockage ());
+       }
+
          switch (tls_kind)
            {
            case TLS_MODEL_GLOBAL_DYNAMIC:
              tga_ret = gen_rtx_REG (Pmode, R0_REG);
              emit_call_insn (gen_tls_global_dynamic (tga_ret, op1));
-             op1 = tga_ret;
+             tmp = gen_reg_rtx (Pmode);
+             emit_move_insn (tmp, tga_ret);
+             op1 = tmp;
              break;
 
            case TLS_MODEL_LOCAL_DYNAMIC:
@@ -1869,18 +1887,6 @@ prepare_move_operands (rtx operands[], enum machine_mode mode)
              break;
 
            case TLS_MODEL_INITIAL_EXEC:
-             if (! flag_pic)
-               {
-                 /* 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_use (gen_rtx_REG (SImode, PIC_REG));
-                 if (flag_schedule_insns)
-                   emit_insn (gen_blockage ());
-               }
              tga_op1 = !can_create_pseudo_p () ? op0 : gen_reg_rtx (Pmode);
              tmp = gen_sym2GOTTPOFF (op1);
              emit_insn (gen_tls_initial_exec (tga_op1, tmp));