[Bug c++/55442] G++ uses up all my RAM when compiling a constexpr with exponential call graph

2019-06-28 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55442

Jason Merrill  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED
   Target Milestone|--- |10.0

--- Comment #4 from Jason Merrill  ---
Fixed for GCC 10.

[Bug c++/55442] G++ uses up all my RAM when compiling a constexpr with exponential call graph

2019-06-27 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55442

--- Comment #3 from Jason Merrill  ---
Author: jason
Date: Thu Jun 27 21:29:19 2019
New Revision: 272765

URL: https://gcc.gnu.org/viewcvs?rev=272765=gcc=rev
Log:
PR c++/55442 - memory-hog with highly recursive constexpr.

This testcase in the PR is extremely recursive, and therefore uses a huge
amount of memory on caching the results of individual calls.  We no longer
need to track all calls to catch infinite recursion, as we have other limits
on maximum depth and operations count.  So let's only cache a few calls at
the top level: 8 seems to be a reasonable compromise.

gcc/c-family/
* c.opt (fconstexpr-loop-limit): New.
gcc/cp/
* constexpr.c (push_cx_call_context): Return depth.
(cxx_eval_call_expression): Don't cache past constexpr_cache_depth.

Modified:
trunk/gcc/c-family/ChangeLog
trunk/gcc/c-family/c.opt
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/constexpr.c
trunk/gcc/doc/invoke.texi

[Bug c++/55442] G++ uses up all my RAM when compiling a constexpr with exponential call graph

2019-06-26 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55442

Jason Merrill  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |jason at gcc dot gnu.org

[Bug c++/55442] G++ uses up all my RAM when compiling a constexpr with exponential call graph

2019-05-20 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55442

Jason Merrill  changed:

   What|Removed |Added

 CC||jason at gcc dot gnu.org

--- Comment #2 from Jason Merrill  ---
(In reply to David Fendrich from comment #0)
> My guess is that this has something to do with unlimited memoization?

Yes.

GGC memory   GarbageFreed  
  LeakOverheadTimes

[...]
cp/constexpr.c:1761 (cxx_eval_call_expression)   0 :  0.0%0 : 
0.0%   73M: 18.5%0 :  0.0% 2340k
cp/constexpr.c:1420 (cxx_bind_parameters_in_call   182M: 96.7%0 : 
0.0%  182M: 46.2%0 :  0.0% 9362k

Both of these are involved with caching the values of constexpr calls.  Looking
at the code, it seems that we do the second allocation even when we get a cache
hit, and then don't free it, so it builds up until we can do GC later.

[Bug c++/55442] G++ uses up all my RAM when compiling a constexpr with exponential call graph

2012-11-22 Thread hubicka at gcc dot gnu.org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55442



Jan Hubicka hubicka at gcc dot gnu.org changed:



   What|Removed |Added



 Status|UNCONFIRMED |NEW

   Last reconfirmed||2012-11-22

 CC||hubicka at gcc dot gnu.org

 Ever Confirmed|0   |1



--- Comment #1 from Jan Hubicka hubicka at gcc dot gnu.org 2012-11-22 
17:01:08 UTC ---

This seems to be frontend issue

We spend a lot of time in

#102 0x0069ea86 in cxx_eval_constant_expression(constexpr_call const*,

tree_node*, bool, bool, bool*) [clone .part.62] () at

../../gcc/cp/semantics.c:7676

#103 0x0069f869 in cxx_eval_constant_expression(constexpr_call const*,

tree_node*, bool, bool, bool*) [clone .part.62] () at

../../gcc/cp/semantics.c:6789

#104 0x0069f6ab in cxx_eval_constant_expression(constexpr_call const*,

tree_node*, bool, bool, bool*) [clone .part.62] () at

../../gcc/cp/semantics.c:7793

#105 0x0069f1b5 in cxx_eval_constant_expression(constexpr_call const*,

tree_node*, bool, bool, bool*) [clone .part.62] () at

../../gcc/cp/semantics.c:7697

#106 0x006a5b5f in cxx_eval_call_expression(constexpr_call const*,

tree_node*, bool, bool, bool*) () at ../../gcc/cp/semantics.c:6676

#107 0x0069ea86 in cxx_eval_constant_expression(constexpr_call const*,

tree_node*, bool, bool, bool*) [clone .part.62] () at

../../gcc/cp/semantics.c:7676

#108 0x006a55b1 in cxx_eval_call_expression(constexpr_call const*,

tree_node*, bool, bool, bool*) () at ../../gcc/cp/semantics.c:6489

#109 0x0069ea86 in cxx_eval_constant_expression(constexpr_call const*,

tree_node*, bool, bool, bool*) [clone .part.62] () at

../../gcc/cp/semantics.c:7676

#110 0x0069f869 in cxx_eval_constant_expression(constexpr_call const*,

tree_node*, bool, bool, bool*) [clone .part.62] () at

../../gcc/cp/semantics.c:6789

#111 0x0069f6ab in cxx_eval_constant_expression(constexpr_call const*,

tree_node*, bool, bool, bool*) [clone .part.62] () at

../../gcc/cp/semantics.c:7793

#112 0x0069f1b5 in cxx_eval_constant_expression(constexpr_call const*,

tree_node*, bool, bool, bool*) [clone .part.62] () at

../../gcc/cp/semantics.c:7697

#113 0x006a5b5f in cxx_eval_call_expression(constexpr_call const*,

tree_node*, bool, bool, bool*) () at ../../gcc/cp/semantics.c:6676

#114 0x0069ea86 in cxx_eval_constant_expression(constexpr_call const*,

tree_node*, bool, bool, bool*) [clone .part.62] () at

../../gcc/cp/semantics.c:7676

#115 0x0069f869 in cxx_eval_constant_expression(constexpr_call const*,

tree_node*, bool, bool, bool*) [clone .part.62] () at

../../gcc/cp/semantics.c:6789

#116 0x0069f6ab in cxx_eval_constant_expression(constexpr_call const*,

tree_node*, bool, bool, bool*) [clone .part.62] () at

../../gcc/cp/semantics.c:7793

#117 0x0069f1b5 in cxx_eval_constant_expression(constexpr_call const*,

tree_node*, bool, bool, bool*) [clone .part.62] () at

../../gcc/cp/semantics.c:7697

#118 0x006a5b5f in cxx_eval_call_expression(constexpr_call const*,

tree_node*, bool, bool, bool*) () at ../../gcc/cp/semantics.c:6676

#119 0x0069ea86 in cxx_eval_constant_expression(constexpr_call const*,

tree_node*, bool, bool, bool*) [clone .part.62] () at

../../gcc/cp/semantics.c:7676

#120 0x0069f869 in cxx_eval_constant_expression(constexpr_call const*,

tree_node*, bool, bool, bool*) [clone .part.62] () at

../../gcc/cp/semantics.c:6789

#121 0x0069f6ab in cxx_eval_constant_expression(constexpr_call const*,

tree_node*, bool, bool, bool*) [clone .part.62] () at

../../gcc/cp/semantics.c:7793

#122 0x0069f1b5 in cxx_eval_constant_expression(constexpr_call const*,

tree_node*, bool, bool, bool*) [clone .part.62] () at

../../gcc/cp/semantics.c:7697

#123 0x006a5b5f in cxx_eval_call_expression(constexpr_call const*,

tree_node*, bool, bool, bool*) () at ../../gcc/cp/semantics.c:6676

#124 0x0069ea86 in cxx_eval_constant_expression(constexpr_call const*,

tree_node*, bool, bool, bool*) [clone .part.62] () at

../../gcc/cp/semantics.c:7676

#125 0x006a1c1d in cxx_eval_outermost_constant_expr(tree_node*, bool)

() at ../../gcc/cp/semantics.c:7976

#126 0x006a2104 in maybe_constant_value(tree_node*) () at

../../gcc/cp/semantics.c:8080

#127 0x006a2259 in maybe_constant_init(tree_node*) () at

../../gcc/cp/semantics.c:8097

#128 0x005ba0f8 in store_init_value(tree_node*, tree_node*,

vectree_node*, va_gc, vl_embed**, int) () at ../../gcc/cp/typeck2.c:717

#129 0x0053cca1 in check_initializer(tree_node*, tree_node*, int,

vectree_node*, va_gc, vl_embed**) () at ../../gcc/cp/decl.c:5715

#130 0x0054f816 in cp_finish_decl(tree_node*,