aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2019-10-02 16:01:42 -0400
committerJason Merrill <jason@gcc.gnu.org>2019-10-02 16:01:42 -0400
commitb830c28b56fdc3f4b4555200278218b4b49022d2 (patch)
treee8b1d17708df837d5cc016be4106d15e520beff0 /gcc
parentc89844e5d30a5235960a2c627abc9369306fda61 (diff)
downloadgcc-b830c28b56fdc3f4b4555200278218b4b49022d2.zip
gcc-b830c28b56fdc3f4b4555200278218b4b49022d2.tar.gz
gcc-b830c28b56fdc3f4b4555200278218b4b49022d2.tar.bz2
Improve C++ fold caching efficiency.
While looking at concepts caching I noticed that we were clearing the caches unnecessarily for non-constant initialization, which shouldn't affect folding. * typeck2.c (store_init_value): Only clear_cv_and_fold_caches if the value is constant. From-SVN: r276487
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/typeck2.c7
2 files changed, 9 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index baf01e6..275fc9f 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2019-10-02 Jason Merrill <jason@redhat.com>
+
+ * typeck2.c (store_init_value): Only clear_cv_and_fold_caches if the
+ value is constant.
+
2019-09-30 Jason Merrill <jason@redhat.com>
Use hash_map_safe_* functions.
diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
index 58fa54f..ec0e6a7 100644
--- a/gcc/cp/typeck2.c
+++ b/gcc/cp/typeck2.c
@@ -907,9 +907,6 @@ store_init_value (tree decl, tree init, vec<tree, va_gc>** cleanups, int flags)
/* Handle aggregate NSDMI in non-constant initializers, too. */
value = replace_placeholders (value, decl);
- /* DECL may change value; purge caches. */
- clear_cv_and_fold_caches ();
-
/* If the initializer is not a constant, fill in DECL_INITIAL with
the bits that are constant, and then return an expression that
will perform the dynamic initialization. */
@@ -918,6 +915,10 @@ store_init_value (tree decl, tree init, vec<tree, va_gc>** cleanups, int flags)
|| vla_type_p (type)
|| ! reduced_constant_expression_p (value)))
return split_nonconstant_init (decl, value);
+
+ /* DECL may change value; purge caches. */
+ clear_cv_and_fold_caches ();
+
/* If the value is a constant, just put it in DECL_INITIAL. If DECL
is an automatic variable, the middle end will turn this into a
dynamic initialization later. */