public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jan Hubicka <hubicka@kam.mff.cuni.cz>
To: gcc-patches@gcc.gnu.org
Subject: Fix crash in gamess
Date: Sun, 14 Nov 2021 00:51:49 +0100	[thread overview]
Message-ID: <20211113235149.GH13726@kam.mff.cuni.cz> (raw)

Hi,
this patch adds debug counters for pure/const discover and fixes
somewhat embarrasing pasto I made while breaking out ipa_make_function_*
helpers out of propagate_pure_const which led to wrong function being
marked as pure that in turn leads to wrong code.
My apologizes for that.

Bootstrapped/regtested x86_64-linux, comitted.

gcc/ChangeLog:

	PR lto/103211
	* dbgcnt.def (ipa_attr): New counters.
	* ipa-pure-const.c: Include dbgcnt.c
	(ipa_make_function_const): Use debug counter.
	(ipa_make_function_pure): Likewise.
	(propagate_pure_const): Fix bug in my previous change.

diff --git a/gcc/dbgcnt.def b/gcc/dbgcnt.def
index 3a85665a1d7..f8a15f3d1d1 100644
--- a/gcc/dbgcnt.def
+++ b/gcc/dbgcnt.def
@@ -175,6 +175,7 @@ DEBUG_COUNTER (if_after_reload)
 DEBUG_COUNTER (if_conversion)
 DEBUG_COUNTER (if_conversion_tree)
 DEBUG_COUNTER (if_to_switch)
+DEBUG_COUNTER (ipa_attr)
 DEBUG_COUNTER (ipa_cp_bits)
 DEBUG_COUNTER (ipa_cp_values)
 DEBUG_COUNTER (ipa_cp_vr)
diff --git a/gcc/ipa-pure-const.c b/gcc/ipa-pure-const.c
index 5056850c0a8..a332940b55d 100644
--- a/gcc/ipa-pure-const.c
+++ b/gcc/ipa-pure-const.c
@@ -62,6 +62,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "ipa-prop.h"
 #include "ipa-fnsummary.h"
 #include "symtab-thunks.h"
+#include "dbgcnt.h"
 
 /* Lattice values for const and pure functions.  Everything starts out
    being const, then may drop to pure and then neither depending on
@@ -1476,8 +1477,10 @@ ipa_make_function_const (struct cgraph_node *node, bool looping, bool local)
     fprintf (dump_file, "Function found to be %sconst: %s\n",
 	     looping ? "looping " : "",
 	     node->dump_name ());
-  if (!local)
+  if (!local && !looping)
     cdtor = node->call_for_symbol_and_aliases (cdtor_p, NULL, true);
+  if (!dbg_cnt (ipa_attr))
+    return false;
   if (node->set_const_flag (true, looping))
     {
       if (dump_file)
@@ -1511,8 +1514,10 @@ ipa_make_function_pure (struct cgraph_node *node, bool looping, bool local)
     fprintf (dump_file, "Function found to be %spure: %s\n",
 	     looping ? "looping " : "",
 	     node->dump_name ());
-  if (!local)
+  if (!local && !looping)
     cdtor = node->call_for_symbol_and_aliases (cdtor_p, NULL, true);
+  if (!dbg_cnt (ipa_attr))
+    return false;
   if (node->set_pure_flag (true, looping))
     {
       if (dump_file)
@@ -1797,11 +1802,11 @@ propagate_pure_const (void)
 	    switch (this_state)
 	      {
 	      case IPA_CONST:
-		remove_p |= ipa_make_function_const (node, this_looping, false);
+		remove_p |= ipa_make_function_const (w, this_looping, false);
 		break;
 
 	      case IPA_PURE:
-		remove_p |= ipa_make_function_pure (node, this_looping, false);
+		remove_p |= ipa_make_function_pure (w, this_looping, false);
 		break;
 
 	      default:

                 reply	other threads:[~2021-11-13 23:51 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20211113235149.GH13726@kam.mff.cuni.cz \
    --to=hubicka@kam.mff.cuni.cz \
    --cc=gcc-patches@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).