public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Martin Jambor <jamborm@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-5554] ipa: Fix CFG fix-up in IPA-CP transform phase (PR 103441)
Date: Sat, 27 Nov 2021 00:03:07 +0000 (GMT)	[thread overview]
Message-ID: <20211127000307.7C7753858D39@sourceware.org> (raw)

https://gcc.gnu.org/g:9e2e47391b316493b52fbb47b4b992b0863795dd

commit r12-5554-g9e2e47391b316493b52fbb47b4b992b0863795dd
Author: Martin Jambor <mjambor@suse.cz>
Date:   Sat Nov 27 01:00:56 2021 +0100

    ipa: Fix CFG fix-up in IPA-CP transform phase (PR 103441)
    
    I forgot that IPA passes before ipa-inline must not return
    TODO_cleanup_cfg from their transformation function because ordinary
    CFG cleanup does not remove call graph edges associated with removed
    call statements but must use
    delete_unreachable_blocks_update_callgraph instead.  This patch fixes
    that error.
    
    gcc/ChangeLog:
    
    2021-11-26  Martin Jambor  <mjambor@suse.cz>
    
            PR ipa/103441
            * ipa-prop.c (ipcp_transform_function): Call
            delete_unreachable_blocks_update_callgraph instead of returning
            TODO_cleanup_cfg.

Diff:
---
 gcc/ipa-prop.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c
index a297f50e945..bc5643206b9 100644
--- a/gcc/ipa-prop.c
+++ b/gcc/ipa-prop.c
@@ -6001,7 +6001,6 @@ ipcp_transform_function (struct cgraph_node *node)
   struct ipa_func_body_info fbi;
   struct ipa_agg_replacement_value *aggval;
   int param_count;
-  bool something_changed = false;
 
   gcc_checking_assert (cfun);
   gcc_checking_assert (current_function_decl);
@@ -6022,14 +6021,16 @@ ipcp_transform_function (struct cgraph_node *node)
   ipa_populate_param_decls (node, *descriptors);
   std::pair<bool, bool> rr
     = adjust_agg_replacement_values (node, aggval, *descriptors);
-  int retval = rr.second ? TODO_cleanup_cfg : 0;
+  bool cfg_changed = rr.second;
   if (!rr.first)
     {
       vec_free (descriptors);
       if (dump_file)
 	fprintf (dump_file, "  All affected aggregate parameters were either "
 		 "removed or converted into scalars, phase done.\n");
-      return retval;
+      if (cfg_changed)
+	delete_unreachable_blocks_update_callgraph (node, false);
+      return 0;
     }
   if (dump_file)
     ipa_dump_agg_replacement_values (dump_file, aggval);
@@ -6041,11 +6042,12 @@ ipcp_transform_function (struct cgraph_node *node)
   fbi.param_count = param_count;
   fbi.aa_walk_budget = opt_for_fn (node->decl, param_ipa_max_aa_steps);
 
+  bool modified_mem_access = false;
   calculate_dominance_info (CDI_DOMINATORS);
-  ipcp_modif_dom_walker walker (&fbi, descriptors, aggval, &something_changed);
+  ipcp_modif_dom_walker walker (&fbi, descriptors, aggval, &modified_mem_access);
   walker.walk (ENTRY_BLOCK_PTR_FOR_FN (cfun));
   free_dominance_info (CDI_DOMINATORS);
-  bool cfg_changed = walker.cleanup_eh ();
+  cfg_changed |= walker.cleanup_eh ();
 
   int i;
   struct ipa_bb_info *bi;
@@ -6059,14 +6061,10 @@ ipcp_transform_function (struct cgraph_node *node)
   s->m_vr = NULL;
 
   vec_free (descriptors);
-
-  if (!something_changed)
-    return retval;
-
   if (cfg_changed)
     delete_unreachable_blocks_update_callgraph (node, false);
 
-  return retval | TODO_update_ssa_only_virtuals;
+  return modified_mem_access ? TODO_update_ssa_only_virtuals : 0;
 }


                 reply	other threads:[~2021-11-27  0:03 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=20211127000307.7C7753858D39@sourceware.org \
    --to=jamborm@gcc.gnu.org \
    --cc=gcc-cvs@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).