public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jan Hubicka <hubicka@kam.mff.cuni.cz>
To: Jeff Law <jeffreyalaw@gmail.com>
Cc: "H.J. Lu" <hjl.tools@gmail.com>,
	GCC Patches <gcc-patches@gcc.gnu.org>,
	Richard Biener <rguenther@suse.de>
Subject: Re: Basic kill analysis for modref
Date: Mon, 15 Nov 2021 21:56:17 +0100	[thread overview]
Message-ID: <20211115205617.GA72251@kam.mff.cuni.cz> (raw)
In-Reply-To: <4eb689bc-e5b7-0ef9-72b0-1084d8700dcd@gmail.com>

> > > +  if (always_executed
> > > +      && callee_summary->kills.length ()
> > > +      && (!cfun->can_throw_non_call_exceptions
> > > +         || !stmt_could_throw_p (cfun, stmt)))
> > > +    {
> > > +      /* Watch for self recursive updates.  */
> > > +      auto_vec<modref_access_node, 32> saved_kills;
> > > +
> > > +      saved_kills.reserve_exact (callee_summary->kills.length ());
> > > +      saved_kills.splice (callee_summary->kills);
> > > +      for (auto kill : saved_kills)
> > > +       {
> > > +         if (kill.parm_index >= (int)parm_map.length ())
> > > +           continue;
> > > +         modref_parm_map &m
> > > +                 = kill.parm_index == MODREF_STATIC_CHAIN_PARM
> > > +                   ? chain_map
> >                       ^^^^^^^^^^^^^^^^  chain_map  isn't initialized.
> > 
> > This caused:
> > 
> > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103262
> Yup.  It's causing heartburn in various ways in the tester.  I was just
> tracking it down with valgrind...
> jeff

Oops, either me or patch much have mislocated the change within the
function when updating to new tree.  I am testing the following fix and
will cook up a testcase verifying that merging of kills works as
expected.

Thanks!
Honza

diff --git a/gcc/ipa-modref.c b/gcc/ipa-modref.c
index df4612bbff9..4784f68f585 100644
--- a/gcc/ipa-modref.c
+++ b/gcc/ipa-modref.c
@@ -964,38 +980,6 @@ merge_call_side_effects (modref_summary *cur_summary,
   if (flags & (ECF_CONST | ECF_NOVOPS))
     return changed;
 
-  if (always_executed
-      && callee_summary->kills.length ()
-      && (!cfun->can_throw_non_call_exceptions
-	  || !stmt_could_throw_p (cfun, stmt)))
-    {
-      /* Watch for self recursive updates.  */
-      auto_vec<modref_access_node, 32> saved_kills;
-
-      saved_kills.reserve_exact (callee_summary->kills.length ());
-      saved_kills.splice (callee_summary->kills);
-      for (auto kill : saved_kills)
-	{
-	  if (kill.parm_index >= (int)parm_map.length ())
-	    continue;
-	  modref_parm_map &m
-		  = kill.parm_index == MODREF_STATIC_CHAIN_PARM
-		    ? chain_map
-		    : parm_map[kill.parm_index];
-	  if (m.parm_index == MODREF_LOCAL_MEMORY_PARM
-	      || m.parm_index == MODREF_UNKNOWN_PARM
-	      || m.parm_index == MODREF_RETSLOT_PARM
-	      || !m.parm_offset_known)
-	    continue;
-	  modref_access_node n = kill;
-	  n.parm_index = m.parm_index;
-	  n.parm_offset += m.parm_offset;
-	  if (modref_access_node::insert_kill (cur_summary->kills, n,
-					       record_adjustments))
-	    changed = true;
-	}
-    }
-
   /* We can not safely optimize based on summary of callee if it does
      not always bind to current def: it is possible that memory load
      was optimized out earlier which may not happen in the interposed
@@ -1043,6 +1027,38 @@ merge_call_side_effects (modref_summary *cur_summary,
   if (dump_file)
     fprintf (dump_file, "\n");
 
+  if (always_executed
+      && callee_summary->kills.length ()
+      && (!cfun->can_throw_non_call_exceptions
+	  || !stmt_could_throw_p (cfun, stmt)))
+    {
+      /* Watch for self recursive updates.  */
+      auto_vec<modref_access_node, 32> saved_kills;
+
+      saved_kills.reserve_exact (callee_summary->kills.length ());
+      saved_kills.splice (callee_summary->kills);
+      for (auto kill : saved_kills)
+	{
+	  if (kill.parm_index >= (int)parm_map.length ())
+	    continue;
+	  modref_parm_map &m
+		  = kill.parm_index == MODREF_STATIC_CHAIN_PARM
+		    ? chain_map
+		    : parm_map[kill.parm_index];
+	  if (m.parm_index == MODREF_LOCAL_MEMORY_PARM
+	      || m.parm_index == MODREF_UNKNOWN_PARM
+	      || m.parm_index == MODREF_RETSLOT_PARM
+	      || !m.parm_offset_known)
+	    continue;
+	  modref_access_node n = kill;
+	  n.parm_index = m.parm_index;
+	  n.parm_offset += m.parm_offset;
+	  if (modref_access_node::insert_kill (cur_summary->kills, n,
+					       record_adjustments))
+	    changed = true;
+	}
+    }
+
   /* Merge with callee's summary.  */
   changed |= cur_summary->loads->merge (callee_summary->loads, &parm_map,
 					&chain_map, record_adjustments);

  reply	other threads:[~2021-11-15 20:56 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-11 12:58 Jan Hubicka
2021-11-12 10:38 ` Richard Biener
2021-11-12 10:47   ` Jan Hubicka
2021-11-12 11:00     ` Richard Biener
2021-11-14 18:53     ` Jan Hubicka
2021-11-15 18:51       ` H.J. Lu
2021-11-15 19:00         ` Jeff Law
2021-11-15 20:56           ` Jan Hubicka [this message]
2021-11-16  8:19         ` Jan Hubicka

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=20211115205617.GA72251@kam.mff.cuni.cz \
    --to=hubicka@kam.mff.cuni.cz \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hjl.tools@gmail.com \
    --cc=jeffreyalaw@gmail.com \
    --cc=rguenther@suse.de \
    /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).