This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/70452] [5/6 Regression] Regression in C++ parsing performance between 4.9.3 and 5.3.1
- From: "ppalka at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 06 Apr 2016 03:22:46 +0000
- Subject: [Bug c++/70452] [5/6 Regression] Regression in C++ parsing performance between 4.9.3 and 5.3.1
- Auto-submitted: auto-generated
- References: <bug-70452-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70452
--- Comment #12 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Turns out that a single line of code is responsible for the 50MB increase in
memory usage relative to 4.9, and that's the call to unshare_expr in
cxx_eval_call_expression:
/* Associate the bindings with the remapped parms. */
tree bound = new_call.bindings;
tree remapped = parms;
while (bound)
{
tree oparm = TREE_PURPOSE (bound);
tree arg = TREE_VALUE (bound);
gcc_assert (DECL_NAME (remapped) == DECL_NAME (oparm));
/* Don't share a CONSTRUCTOR that might be changed. */
arg = unshare_expr (arg); // <-------
ctx->values->put (remapped, arg);
bound = TREE_CHAIN (bound);
remapped = DECL_CHAIN (remapped);
}
We unshare each function argument unconditionally even though it's only
necessary to do so for CONSTRUCTORs. This apparently creates a lot of garbage.
I wonder if guarding the unsharing with "TREE_CODE (arg) == CONSTRUCTOR" would
be sufficient?