re PR rtl-optimization/6871 (const objects shouldn't be moved to .bss)
authorJason Merrill <jason@redhat.com>
Sat, 15 Mar 2003 01:43:07 +0000 (20:43 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Sat, 15 Mar 2003 01:43:07 +0000 (20:43 -0500)
        PR optimization/6871
        * varasm.c (assemble_variable): Leave constant zeroes in .rodata.

From-SVN: r64387

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

index d715d97dc4e1fc7a078384099939e76c35cbfe87..146eb18973bbf4bcef4729dee95e77b815ac3020 100644 (file)
@@ -1,3 +1,8 @@
+2003-03-14  Jason Merrill  <jason@redhat.com>
+
+       PR optimization/6871
+       * varasm.c (assemble_variable): Leave constant zeroes in .rodata.
+
 2003-03-14  Neil Booth  <neil@daikokuya.co.uk>
 
        * c-opts.c (finish_options): New.
diff --git a/gcc/testsuite/gcc.dg/section1.c b/gcc/testsuite/gcc.dg/section1.c
new file mode 100644 (file)
index 0000000..e907f19
--- /dev/null
@@ -0,0 +1,5 @@
+/* PR optimization/6871 */
+/* Constant variables belong in .rodata, not .bss.  */
+/* { dg-final { scan-assembler-not "\.bss" } } */
+
+const int i = 0;
index dea352a9097f112666292348d04ef941ba381025..42775dca5bc692b0e6bae5ed4685f693b58e6dd5 100644 (file)
@@ -1551,6 +1551,8 @@ assemble_variable (decl, top_level, at_end, dont_output_data)
   else if (DECL_INITIAL (decl) == 0
           || DECL_INITIAL (decl) == error_mark_node
           || (flag_zero_initialized_in_bss
+              /* Leave constant zeroes in .rodata so they can be shared.  */
+              && !TREE_READONLY (decl)
               && initializer_zerop (DECL_INITIAL (decl))))
     {
       unsigned HOST_WIDE_INT size = tree_low_cst (DECL_SIZE_UNIT (decl), 1);