aboutsummaryrefslogtreecommitdiff
path: root/gcc/doc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2019-06-27 17:29:19 -0400
committerJason Merrill <jason@gcc.gnu.org>2019-06-27 17:29:19 -0400
commit7ffc7de55b058e78cbc46803b89b712849ea35b3 (patch)
tree45cdc9befe6ccde50d84263ddfe64923c8a031a9 /gcc/doc
parent95bb6e7a56d17f5f8886815f85dff71d12964245 (diff)
downloadgcc-7ffc7de55b058e78cbc46803b89b712849ea35b3.zip
gcc-7ffc7de55b058e78cbc46803b89b712849ea35b3.tar.gz
gcc-7ffc7de55b058e78cbc46803b89b712849ea35b3.tar.bz2
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. From-SVN: r272765
Diffstat (limited to 'gcc/doc')
-rw-r--r--gcc/doc/invoke.texi16
1 files changed, 14 insertions, 2 deletions
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 04fd504..6382a84 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -209,8 +209,9 @@ in the following sections.
@xref{C++ Dialect Options,,Options Controlling C++ Dialect}.
@gccoptlist{-fabi-version=@var{n} -fno-access-control @gol
-faligned-new=@var{n} -fargs-in-order=@var{n} -fchar8_t -fcheck-new @gol
--fconstexpr-depth=@var{n} -fconstexpr-loop-limit=@var{n} @gol
--fconstexpr-ops-limit=@var{n} -fno-elide-constructors @gol
+-fconstexpr-depth=@var{n} -fconstexpr-cache-depth=@var{n} @gol
+-fconstexpr-loop-limit=@var{n} -fconstexpr-ops-limit=@var{n} @gol
+-fno-elide-constructors @gol
-fno-enforce-eh-specs @gol
-fno-gnu-keywords @gol
-fno-implicit-templates @gol
@@ -2527,6 +2528,17 @@ to @var{n}. A limit is needed to detect endless recursion during
constant expression evaluation. The minimum specified by the standard
is 512.
+@item -fconstexpr-cache-depth=@var{n}
+@opindex fconstexpr-cache-depth
+Set the maximum level of nested evaluation depth for C++11 constexpr
+functions that will be cached to @var{n}. This is a heuristic that
+trades off compilation speed (when the cache avoids repeated
+calculations) against memory consumption (when the cache grows very
+large from highly recursive evaluations). The default is 8. Very few
+users are likely to want to adjust it, but if your code does heavy
+constexpr calculations you might want to experiment to find which
+value works best for you.
+
@item -fconstexpr-loop-limit=@var{n}
@opindex fconstexpr-loop-limit
Set the maximum number of iterations for a loop in C++14 constexpr functions