]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR rtl-optimization/66891 (ICE in expand_call, at calls.c:3407)
authorUros Bizjak <ubizjak@gmail.com>
Thu, 30 Jul 2015 08:53:48 +0000 (10:53 +0200)
committerUros Bizjak <uros@gcc.gnu.org>
Thu, 30 Jul 2015 08:53:48 +0000 (10:53 +0200)
Backport from mainline:
2015-07-17  Uros Bizjak  <ubizjak@gmail.com>

PR rtl-optimization/66891
* calls.c (expand_call): Wrap precompute_register_parameters with
NO_DEFER_POP/OK_DEFER_POP to prevent deferred pops.

2015-07-15  Uros Bizjak  <ubizjak@gmail.com>

PR target/58066
* config/i386/i386.md (*tls_global_dynamic_64_<mode>): Depend on SP_REG.
(*tls_local_dynamic_base_64_<mode>): Ditto.
(*tls_local_dynamic_base_64_largepic): Ditto.
(tls_global_dynamic_64_<mode>): Update expander pattern.
(tls_local_dynamic_base_64_<mode>): Ditto.

2015-07-15  Uros Bizjak  <ubizjak@gmail.com>

PR rtl-optimization/58066
* calls.c (expand_call): Precompute register parameters before stack
alignment is performed.

2014-05-08  Wei Mi  <wmi@google.com>

PR target/58066
* config/i386/i386.c (ix86_compute_frame_layout): Update
preferred_stack_boundary for call, expanded from tls descriptor.
* config/i386/i386.md (*tls_global_dynamic_32_gnu): Update RTX
to depend on SP register.
(*tls_local_dynamic_base_32_gnu): Ditto.
(*tls_local_dynamic_32_once): Ditto.
(tls_global_dynamic_64_<mode>): Set
ix86_tls_descriptor_calls_expanded_in_cfun.
(tls_local_dynamic_base_64_<mode>): Ditto.
(tls_global_dynamic_32): Set
ix86_tls_descriptor_calls_expanded_in_cfun. Update RTX
to depend on SP register.
(tls_local_dynamic_base_32): Ditto.

testsuite/ChangeLog:

Backport from mainline:
2015-07-17  Uros Bizjak  <ubizjak@gmail.com>

PR target/66891
* gcc.target/i386/pr66891.c: New test.

2014-05-18  Wei Mi  <wmi@google.com>

PR target/58066
* gcc.target/i386/pr58066.c: Replace pattern matching of .cfi
directive with rtl insns. Add effective-target fpic and
tls_native.

2014-05-08  Wei Mi  <wmi@google.com>

PR target/58066
* gcc.target/i386/pr58066.c: New test.

From-SVN: r226389

gcc/ChangeLog
gcc/config/i386/i386.c
gcc/config/i386/i386.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/pr58066.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/pr66891.c [new file with mode: 0644]

index d37a924218d019be6c68c1afc90f5165403b7aed..08402b15693a1f397f7ec1c3b28516d6c084e60b 100644 (file)
@@ -1,3 +1,44 @@
+2015-07-30  Uros Bizjak  <ubizjak@gmail.com>
+
+       Backport from mainline:
+       2015-07-17  Uros Bizjak  <ubizjak@gmail.com>
+
+       PR rtl-optimization/66891
+       * calls.c (expand_call): Wrap precompute_register_parameters with
+       NO_DEFER_POP/OK_DEFER_POP to prevent deferred pops.
+
+       2015-07-15  Uros Bizjak  <ubizjak@gmail.com>
+
+       PR target/58066
+       * config/i386/i386.md (*tls_global_dynamic_64_<mode>): Depend on SP_REG.
+       (*tls_local_dynamic_base_64_<mode>): Ditto.
+       (*tls_local_dynamic_base_64_largepic): Ditto.
+       (tls_global_dynamic_64_<mode>): Update expander pattern.
+       (tls_local_dynamic_base_64_<mode>): Ditto.
+
+       2015-07-15  Uros Bizjak  <ubizjak@gmail.com>
+
+       PR rtl-optimization/58066
+       * calls.c (expand_call): Precompute register parameters before stack
+       alignment is performed.
+
+       2014-05-08  Wei Mi  <wmi@google.com>
+
+       PR target/58066
+       * config/i386/i386.c (ix86_compute_frame_layout): Update
+       preferred_stack_boundary for call, expanded from tls descriptor.
+       * config/i386/i386.md (*tls_global_dynamic_32_gnu): Update RTX
+       to depend on SP register.
+       (*tls_local_dynamic_base_32_gnu): Ditto.
+       (*tls_local_dynamic_32_once): Ditto.
+       (tls_global_dynamic_64_<mode>): Set
+       ix86_tls_descriptor_calls_expanded_in_cfun.
+       (tls_local_dynamic_base_64_<mode>): Ditto.
+       (tls_global_dynamic_32): Set
+       ix86_tls_descriptor_calls_expanded_in_cfun. Update RTX
+       to depend on SP register.
+       (tls_local_dynamic_base_32): Ditto.
+
 2015-07-25  Tom de Vries  <tom@codesourcery.com>
 
        backport from trunk:
index 704e98639620181f1931f56ae3cde803858e7db8..716b766e4ad5227327d931fbcd5bc7ad1cfc48e3 100644 (file)
@@ -9519,20 +9519,30 @@ ix86_compute_frame_layout (struct ix86_frame *frame)
   frame->nregs = ix86_nsaved_regs ();
   frame->nsseregs = ix86_nsaved_sseregs ();
 
-  stack_alignment_needed = crtl->stack_alignment_needed / BITS_PER_UNIT;
-  preferred_alignment = crtl->preferred_stack_boundary / BITS_PER_UNIT;
-
   /* 64-bit MS ABI seem to require stack alignment to be always 16 except for
      function prologues and leaf.  */
-  if ((TARGET_64BIT_MS_ABI && preferred_alignment < 16)
+  if ((TARGET_64BIT_MS_ABI && crtl->preferred_stack_boundary < 128)
       && (!crtl->is_leaf || cfun->calls_alloca != 0
           || ix86_current_function_calls_tls_descriptor))
     {
-      preferred_alignment = 16;
-      stack_alignment_needed = 16;
       crtl->preferred_stack_boundary = 128;
       crtl->stack_alignment_needed = 128;
     }
+  /* preferred_stack_boundary is never updated for call
+     expanded from tls descriptor. Update it here. We don't update it in
+     expand stage because according to the comments before
+     ix86_current_function_calls_tls_descriptor, tls calls may be optimized
+     away.  */
+  else if (ix86_current_function_calls_tls_descriptor
+          && crtl->preferred_stack_boundary < PREFERRED_STACK_BOUNDARY)
+    {
+      crtl->preferred_stack_boundary = PREFERRED_STACK_BOUNDARY;
+      if (crtl->stack_alignment_needed < PREFERRED_STACK_BOUNDARY)
+       crtl->stack_alignment_needed = PREFERRED_STACK_BOUNDARY;
+    }
+
+  stack_alignment_needed = crtl->stack_alignment_needed / BITS_PER_UNIT;
+  preferred_alignment = crtl->preferred_stack_boundary / BITS_PER_UNIT;
 
   gcc_assert (!size || stack_alignment_needed);
   gcc_assert (preferred_alignment >= STACK_BOUNDARY / BITS_PER_UNIT);
index 823d825d875ad7836ae6f8a9761ecda9af2308a5..2b19f6e307ecf0fbc2b410bd6457b02dd85569c7 100644 (file)
        (unspec:SI
         [(match_operand:SI 1 "register_operand" "b")
          (match_operand 2 "tls_symbolic_operand")
-         (match_operand 3 "constant_call_address_operand" "z")]
+         (match_operand 3 "constant_call_address_operand" "z")
+         (reg:SI SP_REG)]
         UNSPEC_TLS_GD))
    (clobber (match_scratch:SI 4 "=d"))
    (clobber (match_scratch:SI 5 "=c"))
     [(set (match_operand:SI 0 "register_operand")
          (unspec:SI [(match_operand:SI 2 "register_operand")
                      (match_operand 1 "tls_symbolic_operand")
-                     (match_operand 3 "constant_call_address_operand")]
+                     (match_operand 3 "constant_call_address_operand")
+                     (reg:SI SP_REG)]
                     UNSPEC_TLS_GD))
      (clobber (match_scratch:SI 4))
      (clobber (match_scratch:SI 5))
-     (clobber (reg:CC FLAGS_REG))])])
+     (clobber (reg:CC FLAGS_REG))])]
+  ""
+  "ix86_tls_descriptor_calls_expanded_in_cfun = true;")
 
 (define_insn "*tls_global_dynamic_64_<mode>"
   [(set (match_operand:P 0 "register_operand" "=a")
        (call:P
         (mem:QI (match_operand 2 "constant_call_address_operand" "z"))
         (match_operand 3)))
-   (unspec:P [(match_operand 1 "tls_symbolic_operand")]
+   (unspec:P [(match_operand 1 "tls_symbolic_operand")
+             (reg:P SP_REG)]
             UNSPEC_TLS_GD)]
   "TARGET_64BIT"
 {
         (mem:QI (plus:DI (match_operand:DI 2 "register_operand" "b")
                          (match_operand:DI 3 "immediate_operand" "i")))
         (match_operand 4)))
-   (unspec:DI [(match_operand 1 "tls_symbolic_operand")]
-            UNSPEC_TLS_GD)]
+   (unspec:DI [(match_operand 1 "tls_symbolic_operand")
+              (reg:DI SP_REG)]
+             UNSPEC_TLS_GD)]
   "TARGET_64BIT && ix86_cmodel == CM_LARGE_PIC && !TARGET_PECOFF
    && GET_CODE (operands[3]) == CONST
    && GET_CODE (XEXP (operands[3], 0)) == UNSPEC
          (call:P
           (mem:QI (match_operand 2))
           (const_int 0)))
-     (unspec:P [(match_operand 1 "tls_symbolic_operand")]
+     (unspec:P [(match_operand 1 "tls_symbolic_operand")
+               (reg:P SP_REG)]
               UNSPEC_TLS_GD)])]
-  "TARGET_64BIT")
+  "TARGET_64BIT"
+  "ix86_tls_descriptor_calls_expanded_in_cfun = true;")
 
 (define_insn "*tls_local_dynamic_base_32_gnu"
   [(set (match_operand:SI 0 "register_operand" "=a")
        (unspec:SI
         [(match_operand:SI 1 "register_operand" "b")
-         (match_operand 2 "constant_call_address_operand" "z")]
+         (match_operand 2 "constant_call_address_operand" "z")
+         (reg:SI SP_REG)]
         UNSPEC_TLS_LD_BASE))
    (clobber (match_scratch:SI 3 "=d"))
    (clobber (match_scratch:SI 4 "=c"))
      [(set (match_operand:SI 0 "register_operand")
           (unspec:SI
            [(match_operand:SI 1 "register_operand")
-            (match_operand 2 "constant_call_address_operand")]
+            (match_operand 2 "constant_call_address_operand")
+            (reg:SI SP_REG)]
            UNSPEC_TLS_LD_BASE))
       (clobber (match_scratch:SI 3))
       (clobber (match_scratch:SI 4))
-      (clobber (reg:CC FLAGS_REG))])])
+      (clobber (reg:CC FLAGS_REG))])]
+  ""
+  "ix86_tls_descriptor_calls_expanded_in_cfun = true;")
 
 (define_insn "*tls_local_dynamic_base_64_<mode>"
   [(set (match_operand:P 0 "register_operand" "=a")
        (call:P
         (mem:QI (match_operand 1 "constant_call_address_operand" "z"))
         (match_operand 2)))
-   (unspec:P [(const_int 0)] UNSPEC_TLS_LD_BASE)]
+   (unspec:P [(reg:P SP_REG)] UNSPEC_TLS_LD_BASE)]
   "TARGET_64BIT"
 {
   output_asm_insn
         (mem:QI (plus:DI (match_operand:DI 1 "register_operand" "b")
                          (match_operand:DI 2 "immediate_operand" "i")))
         (match_operand 3)))
-   (unspec:DI [(const_int 0)] UNSPEC_TLS_LD_BASE)]
+   (unspec:DI [(reg:DI SP_REG)] UNSPEC_TLS_LD_BASE)]
   "TARGET_64BIT && ix86_cmodel == CM_LARGE_PIC && !TARGET_PECOFF
    && GET_CODE (operands[2]) == CONST
    && GET_CODE (XEXP (operands[2], 0)) == UNSPEC
           (call:P
            (mem:QI (match_operand 1))
            (const_int 0)))
-      (unspec:P [(const_int 0)] UNSPEC_TLS_LD_BASE)])]
-  "TARGET_64BIT")
+      (unspec:P [(reg:P SP_REG)] UNSPEC_TLS_LD_BASE)])]
+  "TARGET_64BIT"
+  "ix86_tls_descriptor_calls_expanded_in_cfun = true;")
 
 ;; Local dynamic of a single variable is a lose.  Show combine how
 ;; to convert that back to global dynamic.
   [(set (match_operand:SI 0 "register_operand" "=a")
        (plus:SI
         (unspec:SI [(match_operand:SI 1 "register_operand" "b")
-                    (match_operand 2 "constant_call_address_operand" "z")]
+                    (match_operand 2 "constant_call_address_operand" "z")
+                    (reg:SI SP_REG)]
                    UNSPEC_TLS_LD_BASE)
         (const:SI (unspec:SI
                    [(match_operand 3 "tls_symbolic_operand")]
   ""
   [(parallel
      [(set (match_dup 0)
-          (unspec:SI [(match_dup 1) (match_dup 3) (match_dup 2)]
+          (unspec:SI [(match_dup 1) (match_dup 3) (match_dup 2)
+                      (reg:SI SP_REG)]
                      UNSPEC_TLS_GD))
       (clobber (match_dup 4))
       (clobber (match_dup 5))
index b202cfe6dd967b50573b739b86685cdef5b838cd..cc6603b24cf5f656db5aa53e74fa91fff598eb49 100644 (file)
@@ -1,3 +1,23 @@
+2015-07-30  Uros Bizjak  <ubizjak@gmail.com>
+
+       Backport from mainline:
+       2015-07-17  Uros Bizjak  <ubizjak@gmail.com>
+
+       PR target/66891
+       * gcc.target/i386/pr66891.c: New test.
+
+       2014-05-18  Wei Mi  <wmi@google.com>
+
+       PR target/58066
+       * gcc.target/i386/pr58066.c: Replace pattern matching of .cfi
+       directive with rtl insns. Add effective-target fpic and
+       tls_native.
+
+       2014-05-08  Wei Mi  <wmi@google.com>
+
+       PR target/58066
+       * gcc.target/i386/pr58066.c: New test.
+
 2015-07-25  Tom de Vries  <tom@codesourcery.com>
 
        backport from trunk:
diff --git a/gcc/testsuite/gcc.target/i386/pr58066.c b/gcc/testsuite/gcc.target/i386/pr58066.c
new file mode 100644 (file)
index 0000000..c8feb4e
--- /dev/null
@@ -0,0 +1,22 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target tls_native } */
+/* { dg-require-effective-target fpic } */
+/* { dg-options "-fPIC -fomit-frame-pointer -O2 -fdump-rtl-final" } */
+
+/* Check whether the stack frame starting addresses of tls expanded calls
+   in foo and goo are 16bytes aligned.  */
+static __thread char ccc1;
+void* foo()
+{
+ return &ccc1;
+}
+
+__thread char ccc2;
+void* goo()
+{
+ return &ccc2;
+}
+
+/* { dg-final { scan-rtl-dump "Function foo.*set\[^\r\n\]*sp\\)\[\r\n\]\[^\r\n\]*plus\[^\r\n\]*sp\\)\[\r\n\]\[^\r\n\]*const_int -8.*UNSPEC_TLS.*Function goo" "final" } } */
+/* { dg-final { scan-rtl-dump "Function goo.*set\[^\r\n\]*sp\\)\[\r\n\]\[^\r\n\]*plus\[^\r\n\]*sp\\)\[\r\n\]\[^\r\n\]*const_int -8.*UNSPEC_TLS" "final" } } */
+/* { dg-final { cleanup-rtl-dump "final" } } */
diff --git a/gcc/testsuite/gcc.target/i386/pr66891.c b/gcc/testsuite/gcc.target/i386/pr66891.c
new file mode 100644 (file)
index 0000000..61a4570
--- /dev/null
@@ -0,0 +1,16 @@
+/* { dg-do compile { target ia32 } } */
+/* { dg-options "-O2" } */
+
+__attribute__((__stdcall__)) void fn1();
+
+int a;
+
+static void fn2() {
+  for (;;)
+    ;
+}
+
+void fn3() {
+  fn1(0);
+  fn2(a == 0);
+}