> On Fri, Nov 13, 2020 at 12:07 AM Richard Biener <rguent...@suse.de> wrote:
> >
> > On Tue, 10 Nov 2020, Jan Hubicka wrote:
> >
> > > Hi,
> > > here is updaed patch.
> > >
> > > Honza
> > >
> > > Bootstrapped/regtested x86_64-linux, OK (after the fnspec fixes)?
> >
> > OK.
> >
> > Thanks,
> > Richard.
> >
> 
> This caused:
> 
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97836

I have pushed the following fix as obvious.  The problem is caused by
fact that I made ipa-modref to set EAF_UNUSED flag for parameters that
are used as scalars but not used to read memory since that suits the
use of the flag in tree-ssa-alias and mostly tree-ssa-structalias with
exception of the rule of escaping to return value.

At monday I will disuss with Richard if we want to adjust EAF_UNUSED or
invernt EAF_NOREAD, but this should prevent wrong code issues.

Honza

2020-11-15  Jan Hubicka  <hubi...@ucw.cz>

        PR ipa/97836
        * ipa-modref.c (analyze_ssa_name_flags): Make return to clear
        EAF_UNUSED flag.

gcc/testsuite/ChangeLog:

2020-11-15  Jan Hubicka  <hubi...@ucw.cz>

        * gcc.c-torture/execute/pr97836.c: New test.

diff --git a/gcc/ipa-modref.c b/gcc/ipa-modref.c
index 5273c200f00..4a43c50aa66 100644
--- a/gcc/ipa-modref.c
+++ b/gcc/ipa-modref.c
@@ -1224,10 +1224,12 @@ analyze_ssa_name_flags (tree name, vec<unsigned char> 
&known_flags, int depth)
          print_gimple_stmt (dump_file, use_stmt, 0);
        }
 
-      /* Gimple return may load the return value.  */
+      /* Gimple return may load the return value.
+        Returning name counts as an use by tree-ssa-structalias.c  */
       if (greturn *ret = dyn_cast <greturn *> (use_stmt))
        {
-         if (memory_access_to (gimple_return_retval (ret), name))
+         if (memory_access_to (gimple_return_retval (ret), name)
+             || name == gimple_return_retval (ret))
            flags &= ~EAF_UNUSED;
        }
       /* Account for LHS store, arg loads and flags from callee function.  */
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr97836.c 
b/gcc/testsuite/gcc.c-torture/execute/pr97836.c
new file mode 100644
index 00000000000..4585e1fc69d
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/pr97836.c
@@ -0,0 +1,17 @@
+int a;
+
+int b(int c) { return 0; }
+
+static int *d(int *e) {
+  if (a) {
+    a = a && b(*e);
+  }
+  return e;
+}
+
+int main() {
+  int f;
+  if (d(&f) != &f)
+    __builtin_abort();
+  return 0;
+}

Reply via email to