From: Jason Merrill Date: Sat, 15 Mar 2003 01:43:07 +0000 (-0500) Subject: re PR rtl-optimization/6871 (const objects shouldn't be moved to .bss) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=af75fb675d7e451df34a1114b236e2291ee5f638;p=gcc.git re PR rtl-optimization/6871 (const objects shouldn't be moved to .bss) PR optimization/6871 * varasm.c (assemble_variable): Leave constant zeroes in .rodata. From-SVN: r64387 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d715d97dc4e..146eb18973b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2003-03-14 Jason Merrill + + PR optimization/6871 + * varasm.c (assemble_variable): Leave constant zeroes in .rodata. + 2003-03-14 Neil Booth * 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 index 00000000000..e907f193b0f --- /dev/null +++ b/gcc/testsuite/gcc.dg/section1.c @@ -0,0 +1,5 @@ +/* PR optimization/6871 */ +/* Constant variables belong in .rodata, not .bss. */ +/* { dg-final { scan-assembler-not "\.bss" } } */ + +const int i = 0; diff --git a/gcc/varasm.c b/gcc/varasm.c index dea352a9097..42775dca5bc 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -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);