On 1/9/20 4:37 PM, Jakub Jelinek wrote:
On Thu, Jan 09, 2020 at 04:27:09PM -0500, Jason Merrill wrote:
Isn't the right spot to fix this somewhere in cp_gimplify_expr?
I mean, the way gimplification works, we unshare_body first and then
gimplify, which is destructive for the GENERIC it is gimplifying.  The
reason why this testcase FAILs is that the gimplification hook after
the unshare_body emits I guess a CONSTRUCTOR multiple times, readding there
the sharing.  Unsharing in gimplify_init_constructor means that for non-C++
or even for C++ when it doesn't trigger the problematic case we unshare the
second time and waste compile time memory.

Yes.  The places we call cp_genericize_tree, we probably also want to call
copy_if_shared (which will need to be exported from gimplify.c).

If it is about CONSTRUCTOR etc. trees we bring in from constexpr caches
and we bring them in during cp_gimplify_expr langhook, not sure how that can
work, because those CONSTRUCTORs probably don't have TREE_VISITED from the
start and so we'd copy them only the second and following time we use them.
As gimplification is destructive, wouldn't the first function that uses them
already mangle them inside of the caches?
I'd say we need to keep in the caches one copy and unshare whenever we want
to use it in some function, which is something unshare_expr can do.

True, cxx_eval_outermost_constant_expr needs to stop assuming that CONSTRUCTORs are already unshared.

Jason

Reply via email to