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 ipa/108007] [11/12/13/14 Regression] wrong code at -Os and above with "-fno-dce -fno-tree-dce" on x86_64-linux-gnu since r10-3311-gff6686d2e5f797
Date: Wed, 24 Jan 2024 18:14:24 +0000	[thread overview]
Message-ID: <bug-108007-4-qyRt07d8xj@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-108007-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #21 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Martin Jambor <jamborm@gcc.gnu.org>:

https://gcc.gnu.org/g:a9a8426e534760b8d3a250e9bd3cff4db131a2be

commit r14-8398-ga9a8426e534760b8d3a250e9bd3cff4db131a2be
Author: Martin Jambor <mjambor@suse.cz>
Date:   Wed Jan 24 19:12:31 2024 +0100

    ipa: Self-DCE of uses of removed call LHSs (PR 108007)

    PR 108007 is another manifestation where we rely on DCE to clean-up
    after IPA-SRA and if the user explicitely switches DCE off, IPA-SRA
    can leave behind statements which are fed uninitialized values and
    trap, even though their results are themselves never used.

    I have already fixed this for unused parameters in callees, this bug
    shows that almost the same thing can happen for removed returns, on
    the side of callers.  This means that the issue has to be fixed
    elsewhere, in call redirection.  This patch adds a function which
    looks for (and through, using a work-list) uses of operations fed
    specific SSA names and removes them all.

    That would have been easy if it wasn't for debug statements during
    tree-inline (from which call redirection is also invoked).  Debug
    statements are decoupled from the rest at this point and iterating
    over uses of SSAs does not bring them up.  During tree-inline they are
    handled especially at the end, I assume in order to make sure that
    relative ordering of UIDs are the same with and without debug info.

    This means that during tree-inline we need to make a hash of killed
    SSAs, that we already have in copy_body_data, available to the
    function making the purging.  So the patch duly does also that, making
    the interface slightly ugly.  Moreover, all newly unused SSA names
    need to be freed and as PR 112616 showed, it must be done in a defined
    order, which is what newly added ipa_release_ssas_in_hash does.

    gcc/ChangeLog:

    2024-01-12  Martin Jambor  <mjambor@suse.cz>

            PR ipa/108007
            PR ipa/112616
            * cgraph.h (cgraph_edge): Add a parameter to
            redirect_call_stmt_to_callee.
            * ipa-param-manipulation.h (ipa_param_adjustments): Add a
            parameter to modify_call.
            (ipa_release_ssas_in_hash): Declare.
            * cgraph.cc (cgraph_edge::redirect_call_stmt_to_callee): New
            parameter killed_ssas, pass it to padjs->modify_call.
            * ipa-param-manipulation.cc (purge_all_uses): New function.
            (ipa_param_adjustments::modify_call): New parameter killed_ssas.
            Instead of substituting uses, invoke purge_all_uses.  If
            hash of killed SSAs has not been provided, create a temporary one
            and release SSAs that have been added to it.
            (compare_ssa_versions): New function.
            (ipa_release_ssas_in_hash): Likewise.
            * tree-inline.cc (redirect_all_calls): Create
            id->killed_new_ssa_names earlier, pass it to edge redirection,
            adjust a comment.
            (copy_body): Release SSAs in id->killed_new_ssa_names.

    gcc/testsuite/ChangeLog:

    2024-01-15  Martin Jambor  <mjambor@suse.cz>

            PR ipa/108007
            PR ipa/112616
            * gcc.dg/ipa/pr108007.c: New test.
            * gcc.dg/ipa/pr112616.c: Likewise.

  parent reply	other threads:[~2024-01-24 18:14 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-07 12:44 [Bug tree-optimization/108007] New: wrong code at -Os and above with "-fno-dce -fno-tree-dce" on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
2022-12-07 16:45 ` [Bug tree-optimization/108007] " pinskia at gcc dot gnu.org
2022-12-07 16:54 ` [Bug ipa/108007] [10/11/12/13 Regression] " pinskia at gcc dot gnu.org
2022-12-07 16:59 ` pinskia at gcc dot gnu.org
2022-12-07 17:00 ` pinskia at gcc dot gnu.org
2022-12-08  9:50 ` marxin at gcc dot gnu.org
2022-12-21 11:41 ` rguenth at gcc dot gnu.org
2023-04-03 14:32 ` jakub at gcc dot gnu.org
2023-04-03 14:35 ` jakub at gcc dot gnu.org
2023-05-12 12:57 ` [Bug ipa/108007] [10/11/12/13/14 " jamborm at gcc dot gnu.org
2023-07-07 10:44 ` [Bug ipa/108007] [11/12/13/14 " rguenth at gcc dot gnu.org
2023-09-20 14:10 ` jamborm at gcc dot gnu.org
2023-09-21  2:15 ` pinskia at gcc dot gnu.org
2023-09-21  2:17 ` pinskia at gcc dot gnu.org
2023-09-21  2:19 ` pinskia at gcc dot gnu.org
2023-09-22 17:30 ` pinskia at gcc dot gnu.org
2023-10-03 16:53 ` cvs-commit at gcc dot gnu.org
2023-10-03 17:18 ` jamborm at gcc dot gnu.org
2023-10-05 12:13 ` jamborm at gcc dot gnu.org
2024-01-11  1:05 ` [Bug ipa/108007] [11/12/13/14 Regression] wrong code at -Os and above with "-fno-dce -fno-tree-dce" on x86_64-linux-gnu since r10-3311-gff6686d2e5f797 pinskia at gcc dot gnu.org
2024-01-16 12:44 ` jamborm at gcc dot gnu.org
2024-01-24 18:14 ` cvs-commit at gcc dot gnu.org [this message]
2024-01-24 19:09 ` jamborm at gcc dot gnu.org
2024-04-08 15:51 ` [Bug ipa/108007] [11/12/13 " cvs-commit at gcc dot gnu.org
2024-05-15 13:46 ` [Bug ipa/108007] [11/12 " cvs-commit 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-108007-4-qyRt07d8xj@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).