public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch] Fix PR 84487, large rodata increase in tonto and other programs
@ 2019-04-13 19:36 Thomas Koenig
  2019-04-14  9:51 ` Paul Richard Thomas
  2019-04-15  7:26 ` Richard Biener
  0 siblings, 2 replies; 19+ messages in thread
From: Thomas Koenig @ 2019-04-13 19:36 UTC (permalink / raw)
  To: fortran, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1170 bytes --]

Hello world,

the attached patch fixes a 8/9 regression where _def_init, an internal
Fortran variable containing only zeros, was placed into the .rodata
section. This led to a large increase in executable size.

There should be no impact on other languages because the change to
varasm.c is guarded by lang_GNU_Fortran ().

Regarding the test case: I did find one other test which checks
for .bss, so I suppose this is safe.

Regression-tested with a full test (--enable-languages=all and
make -j64 -k check) on POWER9.

I would like to apply it to both affected branches.

OK for the general and the Fortran part?

Regards

	Thomas

2019-04-13  Thomas Koenig  <tkoenig@gcc.gnu.org>

         PR fortran/84487
         * trans-decl.c (gfc_get_symbol_decl): Mark _def_init as
         artificial.

2019-04-13  Thomas Koenig  <tkoenig@gcc.gnu.org>

         PR fortran/84487
         * varasm.c (bss_initializer_p): If we are compiling Fortran, the
         decl is artifical and it has a size larger than 255, it can be
         put into BSS.

2019-04-13  Thomas Koenig  <tkoenig@gcc.gnu.org>

         PR fortran/84487
         * gfortran.dg/def_init_1.f90: New test.



[-- Attachment #2: p5.diff --]
[-- Type: text/x-patch, Size: 1523 bytes --]

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, in the Fortran
+     compiler only, above a certain size.  */
+  return ((!TREE_READONLY (decl) || DECL_COMMON (decl) || named
+	   || (lang_GNU_Fortran () && DECL_ARTIFICIAL (decl)
+	       && (tree_to_uhwi (DECL_SIZE_UNIT (decl)) > 255 )))
 	  && (DECL_INITIAL (decl) == NULL
 	      /* In LTO we have no errors in program; error_mark_node is used
 	         to mark offlined constructors.  */

[-- Attachment #3: def_init_1.f90 --]
[-- Type: text/x-fortran, Size: 273 bytes --]

! { dg-do compile }
! PR 84487 - check that def_init, if it is large,
! is put into .bss.
module TYPES_MODULE

  implicit none

  type archive_type
     character(2**18) :: root_name
  end type archive_type
end module TYPES_MODULE
! { dg-final { scan-assembler "\.bss" } }

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2019-04-17 12:55 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-13 19:36 [patch] Fix PR 84487, large rodata increase in tonto and other programs Thomas Koenig
2019-04-14  9:51 ` Paul Richard Thomas
2019-04-15  7:26 ` Richard Biener
2019-04-15 11:54   ` Jan Hubicka
2019-04-15 11:55   ` Florian Weimer
2019-04-15 20:08     ` Segher Boessenkool
2019-04-16 10:06       ` Florian Weimer
2019-04-16 10:12         ` Richard Biener
2019-04-16 10:20           ` Segher Boessenkool
2019-04-16 10:16         ` Segher Boessenkool
2019-04-16 10:17         ` Jakub Jelinek
2019-04-16 10:30           ` Segher Boessenkool
2019-04-17  7:35           ` Thomas König
2019-04-17  8:48             ` Richard Biener
2019-04-17 11:09               ` Florian Weimer
2019-04-17 12:23                 ` Andreas Schwab
2019-04-17 12:45                   ` Florian Weimer
2019-04-17 12:55                     ` Andreas Schwab
2019-04-17 13:13                       ` Florian Weimer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).