This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Putting an all-zero variable into BSS
Hi Richard,
I don't know without looking, but I'd start at assemble_variable in varasm.c.
Thanks. I've done that, and this is what a patch could look like.
However, I will not have time to formally submit this until next
weekend.
In the meantime, comments are still welcome :-)
Regards
Thomas
Index: fortran/trans-decl.c
===================================================================
--- fortran/trans-decl.c (Revision 270182)
+++ fortran/trans-decl.c (Arbeitskopie)
@@ -1865,7 +1865,10 @@ gfc_get_symbol_decl (gfc_symbol * sym)
if (sym->attr.vtab
|| (sym->name[0] == '_' && gfc_str_startswith (sym->name, "__def_init")))
- TREE_READONLY (decl) = 1;
+ {
+ TREE_READONLY (decl) = 1;
+ DECL_ARTIFICIAL (decl) = 1;
+ }
return decl;
}
Index: varasm.c
===================================================================
--- varasm.c (Revision 270182)
+++ varasm.c (Arbeitskopie)
@@ -1007,9 +1007,13 @@ decode_reg_name (const char *name)
bool
bss_initializer_p (const_tree decl, bool named)
{
- /* Do not put non-common constants into the .bss section, they belong in
- a readonly section, except when NAMED is true. */
- return ((!TREE_READONLY (decl) || DECL_COMMON (decl) || named)
+ /* Do not put non-common constants into the .bss section, they
+ belong in a readonly section, except when NAMED is true or when
+ we are dealing with an artificial declaration above a certain
+ size. */
+ return ((!TREE_READONLY (decl) || DECL_COMMON (decl) || named
+ || ((tree_to_uhwi (DECL_SIZE_UNIT (decl)) > 256
+ && DECL_ARTIFICIAL (decl))))
&& (DECL_INITIAL (decl) == NULL
/* In LTO we have no errors in program; error_mark_node is used
to mark offlined constructors. */