re PR middle-end/82095 (ICE in tree_nop_conversion at tree.c:11793 on ppc64le)
authorJakub Jelinek <jakub@redhat.com>
Wed, 6 Sep 2017 09:10:26 +0000 (11:10 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 6 Sep 2017 09:10:26 +0000 (11:10 +0200)
PR middle-end/82095
* varasm.c (categorize_decl_for_section): Use SECCAT_TBSS for TLS vars with
NULL DECL_INITIAL.

* gcc.dg/tls/pr82095.c: New test.

From-SVN: r251754

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tls/pr82095.c [new file with mode: 0644]
gcc/varasm.c

index f6ba412aeb0f3779670e0ee825da210d9faa4eda..e35d6b35b225d9dfb13041aab6ee7c62495fbef7 100644 (file)
@@ -1,3 +1,9 @@
+2017-09-06  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/82095
+       * varasm.c (categorize_decl_for_section): Use SECCAT_TBSS for TLS vars with
+       NULL DECL_INITIAL.
+
 2017-09-06  Richard Biener  <rguenther@suse.de>
 
        * gimple-ssa-strength-reduction.c
index 667d1cbcbba49cfacfa78f8b546cc8d626dd3c67..2b168296cd7e856d1d21cef17c4b8379754260fe 100644 (file)
@@ -1,3 +1,8 @@
+2017-09-06  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/82095
+       * gcc.dg/tls/pr82095.c: New test.
+
 2017-09-05  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/81768
diff --git a/gcc/testsuite/gcc.dg/tls/pr82095.c b/gcc/testsuite/gcc.dg/tls/pr82095.c
new file mode 100644 (file)
index 0000000..5713a3b
--- /dev/null
@@ -0,0 +1,16 @@
+/* PR middle-end/82095 */
+/* { dg-do compile } */
+/* { dg-options "-Og -fno-tree-ccp" } */
+/* { dg-require-effective-target tls } */
+/* { dg-add-options tls } */
+
+static int b;
+static __thread int c;
+
+void
+foo (void)
+{
+  if (b)
+    if (c)
+      b = 1;
+}
index f2a12f0495f229ac608cc21cf88aae980eaea416..6177eec118b29f0c358e65dcdeceec8bf392c9df 100644 (file)
@@ -6562,8 +6562,9 @@ categorize_decl_for_section (const_tree decl, int reloc)
       /* Note that this would be *just* SECCAT_BSS, except that there's
         no concept of a read-only thread-local-data section.  */
       if (ret == SECCAT_BSS
-              || (flag_zero_initialized_in_bss
-                  && initializer_zerop (DECL_INITIAL (decl))))
+         || DECL_INITIAL (decl) == NULL
+         || (flag_zero_initialized_in_bss
+             && initializer_zerop (DECL_INITIAL (decl))))
        ret = SECCAT_TBSS;
       else
        ret = SECCAT_TDATA;