diff options
author | Jan Hubicka <jh@suse.cz> | 2021-12-20 08:43:13 +0100 |
---|---|---|
committer | Jan Hubicka <jh@suse.cz> | 2021-12-20 08:43:13 +0100 |
commit | 8d1e342b4afbad77cb92f8057cf6d1e996bfb077 (patch) | |
tree | b2075a2df6b749ddd9ac4687632c20875c631c8f | |
parent | 19dcecd963295b02b96c8cac57933657dbe3234a (diff) | |
download | gcc-8d1e342b4afbad77cb92f8057cf6d1e996bfb077.zip gcc-8d1e342b4afbad77cb92f8057cf6d1e996bfb077.tar.gz gcc-8d1e342b4afbad77cb92f8057cf6d1e996bfb077.tar.bz2 |
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.
-rw-r--r-- | gcc/ipa-modref.c | 50 | ||||
-rw-r--r-- | 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 9c411a6..733fc21 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 0000000..a9509c3 --- /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; +} |