public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "fxue at os dot amperecomputing.com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/107828] New: tree-inlining would generate SSA with incorrect def stmt
Date: Wed, 23 Nov 2022 01:42:25 +0000	[thread overview]
Message-ID: <bug-107828-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 107828
           Summary: tree-inlining would generate SSA with incorrect def
                    stmt
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fxue at os dot amperecomputing.com
  Target Milestone: ---

In the function "remap_gimple_op_r" of tree-inlining.cc:

  ...

  if (TREE_CODE (*tp) == SSA_NAME)
    {
      *tp = remap_ssa_name (*tp, id);
      *walk_subtrees = 0;
      if (is_lhs)
         SSA_NAME_DEF_STMT (*tp) = wi_p->stmt;
      return NULL;
    }

The definition statement of original "*tp" may be same as wi_p->stmt. So, we
will end up with a statement that it is pointed by both old and new SSA name,
while the old one should have been reclaimed.

And this happens when some parameter needs to be adjusted during inline
versioning as:

remap_gimple_stmt()

{
  ...
  if (id->param_body_adjs)
    {
      ...
      if (!gimple_seq_empty_p (extra_stmts))
        {
          memset (&wi, 0, sizeof (wi));
          wi.info = id;
          for (gimple_stmt_iterator egsi = gsi_start (extra_stmts);
               !gsi_end_p (egsi);
               gsi_next (&egsi))
            walk_gimple_op (gsi_stmt (egsi), remap_gimple_op_r, &wi);
                                             ^^^^^^^^^^^^^^^^^

            ...
        }
    }
   ...
}

             reply	other threads:[~2022-11-23  1:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-23  1:42 fxue at os dot amperecomputing.com [this message]
2022-11-23  9:49 ` [Bug tree-optimization/107828] " marxin at gcc dot gnu.org
2022-12-02 17:39 ` jamborm at gcc dot gnu.org
2022-12-08  9:38 ` marxin at gcc dot gnu.org
2022-12-13 10:04 ` fxue at os dot amperecomputing.com

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-107828-4@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).