aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2017-11-27 08:34:50 +0000
committerJakub Jelinek <jakub@redhat.com>2017-11-27 08:34:50 +0000
commitdbe0767c6c1ed2dceddeea2cae226ed94e3afe3b (patch)
tree6035717443e5050e05a17efca330ad5f79e07d48
parent1c8deb239e322c3850e68146db1d1efa4eb6fb13 (diff)
PR target/83100
* varasm.c (bss_initializer_p): Return true for DECL_COMMON TREE_READONLY decls. * gcc.dg/pr83100-1.c: New test. * gcc.dg/pr83100-2.c: New test. * gcc.dg/pr83100-3.c: New test. * gcc.dg/pr83100-4.c: New test. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@255160 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/testsuite/ChangeLog8
-rw-r--r--gcc/testsuite/gcc.dg/pr83100-1.c7
-rw-r--r--gcc/testsuite/gcc.dg/pr83100-2.c15
-rw-r--r--gcc/testsuite/gcc.dg/pr83100-3.c6
-rw-r--r--gcc/testsuite/gcc.dg/pr83100-4.c7
-rw-r--r--gcc/varasm.c6
7 files changed, 52 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index dc980a96a0d..7189a66ed83 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2017-11-27 Jakub Jelinek <jakub@redhat.com>
+
+ PR target/83100
+ * varasm.c (bss_initializer_p): Return true for DECL_COMMON
+ TREE_READONLY decls.
+
2017-11-27 Markus Trippelsdorf <markus@trippelsdorf.de>
PR rtl-optimization/82488
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index f750ad7b333..ff40f3657e3 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2017-11-27 Jakub Jelinek <jakub@redhat.com>
+
+ PR target/83100
+ * gcc.dg/pr83100-1.c: New test.
+ * gcc.dg/pr83100-2.c: New test.
+ * gcc.dg/pr83100-3.c: New test.
+ * gcc.dg/pr83100-4.c: New test.
+
2017-11-26 Julia Koval <julia.koval@intel.com>
* gcc.target/i386/funcspec-56.inc: Handle new march.
diff --git a/gcc/testsuite/gcc.dg/pr83100-1.c b/gcc/testsuite/gcc.dg/pr83100-1.c
new file mode 100644
index 00000000000..233c1f687b0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr83100-1.c
@@ -0,0 +1,7 @@
+/* PR target/83100 */
+/* { dg-do compile { target *-*-linux* *-*-gnu* } } */
+/* { dg-options "-O2 -fcommon -fdata-sections" } */
+
+const int a;
+
+/* { dg-final { scan-assembler "comm" } } */
diff --git a/gcc/testsuite/gcc.dg/pr83100-2.c b/gcc/testsuite/gcc.dg/pr83100-2.c
new file mode 100644
index 00000000000..6dbe93dcd16
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr83100-2.c
@@ -0,0 +1,15 @@
+/* PR target/83100 */
+/* { dg-do run } */
+/* { dg-options "-O2 -fcommon -fdata-sections" } */
+/* { dg-additional-sources pr83100-3.c } */
+/* { dg-skip-if "-fdata-sections not supported" { hppa*-*-hpux* nvptx-*-* } } */
+
+const int a;
+
+int
+main ()
+{
+ if (a != 7)
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/pr83100-3.c b/gcc/testsuite/gcc.dg/pr83100-3.c
new file mode 100644
index 00000000000..a28e852695f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr83100-3.c
@@ -0,0 +1,6 @@
+/* PR target/83100 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fcommon -fdata-sections" } */
+/* { dg-skip-if "-fdata-sections not supported" { hppa*-*-hpux* nvptx-*-* } } */
+
+const int a = 7;
diff --git a/gcc/testsuite/gcc.dg/pr83100-4.c b/gcc/testsuite/gcc.dg/pr83100-4.c
new file mode 100644
index 00000000000..bb26735dd1b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr83100-4.c
@@ -0,0 +1,7 @@
+/* PR target/83100 */
+/* { dg-do compile { target *-*-linux* *-*-gnu* } } */
+/* { dg-options "-O2 -fno-common -fdata-sections" } */
+
+const int a;
+
+/* { dg-final { scan-assembler "rodata.a" { target i?86-*-* x86_64-*-* } } } */
diff --git a/gcc/varasm.c b/gcc/varasm.c
index 923399d71a4..ff912b7fa57 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -986,9 +986,9 @@ decode_reg_name (const char *name)
bool
bss_initializer_p (const_tree decl)
{
- /* Do not put constants into the .bss section, they belong in a readonly
- section. */
- return (!TREE_READONLY (decl)
+ /* Do not put non-common constants into the .bss section, they belong in
+ a readonly section. */
+ return ((!TREE_READONLY (decl) || DECL_COMMON (decl))
&& (DECL_INITIAL (decl) == NULL
/* In LTO we have no errors in program; error_mark_node is used
to mark offlined constructors. */