This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/70452] [5/6 Regression] Regression in C++ parsing performance between 4.9.3 and 5.3.1


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?

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]