[Bug c++/87436] [7/8 Regression] G++ produces >300MB .rodata section to initialize struct with big array

2019-01-08 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87436

--- Comment #11 from Jakub Jelinek  ---
Author: jakub
Date: Tue Jan  8 10:22:00 2019
New Revision: 267709

URL: https://gcc.gnu.org/viewcvs?rev=267709=gcc=rev
Log:
Backported from mainline
2018-12-14  Jakub Jelinek  

PR c++/82294
PR c++/87436
* expr.h (categorize_ctor_elements): Add p_unique_nz_elts argument.
* expr.c (categorize_ctor_elements_1): Likewise.  Compute it like
p_nz_elts, except don't multiply it by mult.  Adjust recursive call.
Fix up COMPLEX_CST handling.
(categorize_ctor_elements): Add p_unique_nz_elts argument, initialize
it and pass it through to categorize_ctor_elements_1.
(mostly_zeros_p, all_zeros_p): Adjust categorize_ctor_elements callers.
* gimplify.c (gimplify_init_constructor): Likewise.  Don't force
ctor into readonly data section if num_unique_nonzero_elements is
smaller or equal to 1/8 of num_nonzero_elements and size is >= 64
bytes.

* g++.dg/tree-ssa/pr82294.C: New test.
* g++.dg/tree-ssa/pr87436.C: New test.

Added:
branches/gcc-8-branch/gcc/testsuite/g++.dg/tree-ssa/pr82294.C
branches/gcc-8-branch/gcc/testsuite/g++.dg/tree-ssa/pr87436.C
Modified:
branches/gcc-8-branch/gcc/ChangeLog
branches/gcc-8-branch/gcc/expr.c
branches/gcc-8-branch/gcc/expr.h
branches/gcc-8-branch/gcc/gimplify.c
branches/gcc-8-branch/gcc/testsuite/ChangeLog

[Bug c++/87436] [7/8 Regression] G++ produces >300MB .rodata section to initialize struct with big array

2019-01-08 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87436

--- Comment #10 from Jakub Jelinek  ---
Author: jakub
Date: Tue Jan  8 10:20:57 2019
New Revision: 267708

URL: https://gcc.gnu.org/viewcvs?rev=267708=gcc=rev
Log:
Backported from mainline
2018-12-14  Jakub Jelinek  

PR c++/82294
PR c++/87436
* init.c (build_vec_init): Change num_initialized_elts type from int
to HOST_WIDE_INT.  Build a RANGE_EXPR if e needs to be repeated more
than once.

Modified:
branches/gcc-8-branch/gcc/cp/ChangeLog
branches/gcc-8-branch/gcc/cp/init.c

[Bug c++/87436] [7/8 Regression] G++ produces >300MB .rodata section to initialize struct with big array

2018-12-14 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87436

Jakub Jelinek  changed:

   What|Removed |Added

Summary|[7/8/9 Regression] G++  |[7/8 Regression] G++
   |produces >300MB .rodata |produces >300MB .rodata
   |section to initialize   |section to initialize
   |struct with big array   |struct with big array

--- Comment #9 from Jakub Jelinek  ---
Fixed on the trunk.