public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-6072] Fix handling of deferred SSA names in modref dataflow
@ 2021-12-20  7:43 Jan Hubicka
  0 siblings, 0 replies; only message in thread
From: Jan Hubicka @ 2021-12-20  7:43 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:8d1e342b4afbad77cb92f8057cf6d1e996bfb077

commit r12-6072-g8d1e342b4afbad77cb92f8057cf6d1e996bfb077
Author: Jan Hubicka <jh@suse.cz>
Date:   Mon Dec 20 08:43:13 2021 +0100

    Fix handling of deferred SSA names in modref dataflow
    
    In the testcase we fail to analyze SSA name because flag do_dataflow is set
    and thus triggers early exist in analyze_ssa_name.  Fixed by disabling
    early exits when handling deferred names.
    
    gcc/ChangeLog:
    
    2021-12-20  Jan Hubicka  <hubicka@ucw.cz>
    
            PR ipa/103669
            * ipa-modref.c (modref_eaf_analysis::analyze_ssa_name): Add deferred
            parameter.
            (modref_eaf_analysis::propagate): Use it.
    
    gcc/testsuite/ChangeLog:
    
    2021-12-20  Jan Hubicka  <hubicka@ucw.cz>
    
            PR ipa/103669
            * g++.dg/torture/pr103669.C: New test.

Diff:
---
 gcc/ipa-modref.c                        | 50 +++++++++++++++++----------------
 gcc/testsuite/g++.dg/torture/pr103669.C | 22 +++++++++++++++
 2 files changed, 48 insertions(+), 24 deletions(-)

diff --git a/gcc/ipa-modref.c b/gcc/ipa-modref.c
index 9c411a6297a..733fc212fcc 100644
--- a/gcc/ipa-modref.c
+++ b/gcc/ipa-modref.c
@@ -2232,7 +2232,7 @@ class modref_eaf_analysis
 {
 public:
   /* Mark NAME as relevant for analysis.  */
-  void analyze_ssa_name (tree name);
+  void analyze_ssa_name (tree name, bool deferred = false);
   /* Dataflow slover.  */
   void propagate ();
   /* Return flags computed earlier for NAME.  */
@@ -2373,33 +2373,36 @@ callee_to_caller_flags (int call_flags, bool ignore_stores,
    are processed later)  */
 
 void
-modref_eaf_analysis::analyze_ssa_name (tree name)
+modref_eaf_analysis::analyze_ssa_name (tree name, bool deferred)
 {
   imm_use_iterator ui;
   gimple *use_stmt;
   int index = SSA_NAME_VERSION (name);
 
-  /* See if value is already computed.  */
-  if (m_lattice[index].known || m_lattice[index].do_dataflow)
-   return;
-  if (m_lattice[index].open)
+  if (!deferred)
     {
-      if (dump_file)
-	fprintf (dump_file,
-		 "%*sCycle in SSA graph\n",
-		 m_depth * 4, "");
-      return;
-    }
-  /* Recursion guard.  */
-  m_lattice[index].init ();
-  if (m_depth == param_modref_max_depth)
-    {
-      if (dump_file)
-	fprintf (dump_file,
-		 "%*sMax recursion depth reached; postponing\n",
-		 m_depth * 4, "");
-      m_deferred_names.safe_push (name);
-      return;
+      /* See if value is already computed.  */
+      if (m_lattice[index].known || m_lattice[index].do_dataflow)
+       return;
+      if (m_lattice[index].open)
+	{
+	  if (dump_file)
+	    fprintf (dump_file,
+		     "%*sCycle in SSA graph\n",
+		     m_depth * 4, "");
+	  return;
+	}
+      /* Recursion guard.  */
+      m_lattice[index].init ();
+      if (m_depth == param_modref_max_depth)
+	{
+	  if (dump_file)
+	    fprintf (dump_file,
+		     "%*sMax recursion depth reached; postponing\n",
+		     m_depth * 4, "");
+	  m_deferred_names.safe_push (name);
+	  return;
+	}
     }
 
   if (dump_file)
@@ -2742,10 +2745,9 @@ modref_eaf_analysis::propagate ()
   while (m_deferred_names.length ())
     {
       tree name = m_deferred_names.pop ();
-      m_lattice[SSA_NAME_VERSION (name)].open = false;
       if (dump_file)
 	fprintf (dump_file, "Analyzing deferred SSA name\n");
-      analyze_ssa_name (name);
+      analyze_ssa_name (name, true);
     }
 
   if (!m_names_to_propagate.length ())
diff --git a/gcc/testsuite/g++.dg/torture/pr103669.C b/gcc/testsuite/g++.dg/torture/pr103669.C
new file mode 100644
index 00000000000..a9509c354f1
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr103669.C
@@ -0,0 +1,22 @@
+// { dg-do run }
+/* { dg-additional-options "--param=modref-max-depth=1" } */
+#include <list>
+
+typedef std::list<void *> PtrList;
+
+void
+SlList (PtrList *l)
+{
+  PtrList temp = *l;
+  PtrList::iterator iter;
+  for (iter = temp.begin (); iter != temp.end (); ++iter)
+    __builtin_abort ();
+}
+
+int
+main (void)
+{
+  PtrList list;
+  SlList (&list);
+  return 0;
+}


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-12-20  7:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-20  7:43 [gcc r12-6072] Fix handling of deferred SSA names in modref dataflow Jan Hubicka

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).