public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/105838] [10/11/12/13/14 Regression] g++ 12.1.0 runs out of memory or time when building const std::vector of std::strings
Date: Fri, 02 Jun 2023 15:01:30 +0000	[thread overview]
Message-ID: <bug-105838-4-VFJebTrpUb@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-105838-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105838

--- Comment #22 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

https://gcc.gnu.org/g:4d935f52b0d5c00fcc154461b87415ebd8791a94

commit r14-1500-g4d935f52b0d5c00fcc154461b87415ebd8791a94
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Dec 7 11:40:53 2022 -0500

    c++: make initializer_list array static again [PR110070]

    After the maybe_init_list_as_* patches, I noticed that we were putting the
    array of strings into .rodata, but then memcpying it into an automatic
    array, which is pointless; we should be able to use it directly.

    This doesn't happen automatically because TREE_ADDRESSABLE is set (since
    r12-657 for PR100464), and so gimplify_init_constructor won't promote the
    variable to static.  Theoretically we could do escape analysis to recognize
    that the address, though taken, never leaves the function; that would allow
    promotion when we're only using the address for indexing within the
    function, as in initlist-opt2.C.  But this would be a new pass.

    And in initlist-opt1.C, we're passing the array address to another
function,
    so it definitely escapes; it's only safe in this case because it's calling
a
    standard library function that we know only uses it for indexing.  So, a
    flag seems needed.  I first thought to put the flag on the TARGET_EXPR, but
    the VAR_DECL seems more appropriate.

    In a previous revision of the patch I called this flag DECL_NOT_OBSERVABLE,
    but I think DECL_MERGEABLE is a better name, especially if we're going to
    apply it to the backing array of initializer_list, which is observable.  I
    then also check it in places that check for -fmerge-all-constants, so that
    multiple equivalent initializer-lists can also be combined.  And then it
    seemed to make sense for [[no_unique_address]] to have this meaning for
    user-written variables.

    I think the note in [dcl.init.list]/6 intended to allow this kind of
merging
    for initializer_lists, but it didn't actually work; for an explicit array
    with the same initializer, if the address escapes the program could tell
    whether the same variable in two frames have the same address.  P2752 is
    trying to correct this defect, so I'm going to assume that this is the
    intent.

            PR c++/110070
            PR c++/105838

    gcc/ChangeLog:

            * tree.h (DECL_MERGEABLE): New.
            * tree-core.h (struct tree_decl_common): Mention it.
            * gimplify.cc (gimplify_init_constructor): Check it.
            * cgraph.cc (symtab_node::address_can_be_compared_p): Likewise.
            * varasm.cc (categorize_decl_for_section): Likewise.

    gcc/cp/ChangeLog:

            * call.cc (maybe_init_list_as_array): Set DECL_MERGEABLE.
            (convert_like_internal) [ck_list]: Set it.
            (set_up_extended_ref_temp): Copy it.
            * tree.cc (handle_no_unique_addr_attribute): Set it.

    gcc/testsuite/ChangeLog:

            * g++.dg/tree-ssa/initlist-opt1.C: Check for static array.
            * g++.dg/tree-ssa/initlist-opt2.C: Likewise.
            * g++.dg/tree-ssa/initlist-opt4.C: New test.
            * g++.dg/opt/icf1.C: New test.
            * g++.dg/opt/icf2.C: New test.
            * g++.dg/opt/icf3.C: New test.
            * g++.dg/tree-ssa/array-temp1.C: Revert r12-657 change.

  parent reply	other threads:[~2023-06-02 15:01 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-03 16:22 [Bug c++/105838] New: " eisjmbjdfcukqlaely at nthrl dot com
2022-06-13 12:47 ` [Bug c++/105838] " rguenth at gcc dot gnu.org
2022-06-13 12:52 ` rguenth at gcc dot gnu.org
2022-06-14 11:56 ` rguenth at gcc dot gnu.org
2022-06-14 13:10 ` [Bug c++/105838] [10/11/12/13 Regression] " rguenth at gcc dot gnu.org
2022-06-14 13:11 ` rguenth at gcc dot gnu.org
2022-06-14 13:37 ` jakub at gcc dot gnu.org
2022-06-28 10:49 ` jakub at gcc dot gnu.org
2022-07-10 20:39 ` pinskia at gcc dot gnu.org
2022-07-11 15:43 ` luydorarko at vusra dot com
2022-12-05 17:57 ` jason at gcc dot gnu.org
2022-12-05 18:30 ` jakub at gcc dot gnu.org
2022-12-05 20:50 ` jason at gcc dot gnu.org
2022-12-05 20:58 ` jason at gcc dot gnu.org
2022-12-05 22:27 ` redi at gcc dot gnu.org
2022-12-05 22:34 ` jakub at gcc dot gnu.org
2022-12-05 23:57 ` jason at gcc dot gnu.org
2022-12-08 18:34 ` cvs-commit at gcc dot gnu.org
2022-12-08 18:41 ` cvs-commit at gcc dot gnu.org
2022-12-08 18:45 ` cvs-commit at gcc dot gnu.org
2022-12-15  5:26 ` cvs-commit at gcc dot gnu.org
2023-01-09 22:41 ` cvs-commit at gcc dot gnu.org
2023-06-02 15:01 ` cvs-commit at gcc dot gnu.org [this message]
2023-06-12  8:57 ` [Bug c++/105838] [10/11/12 " cvs-commit at gcc dot gnu.org
2023-07-07 10:43 ` [Bug c++/105838] [11/12 " rguenth at gcc dot gnu.org
2023-08-19  9:22 ` fxcoudert at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-105838-4-VFJebTrpUb@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).