tree-ssa-alias.c (ref_maybe_used_by_stmt_p): Handle return statements.
authorRichard Guenther <rguenther@suse.de>
Thu, 21 Apr 2011 11:31:52 +0000 (11:31 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 21 Apr 2011 11:31:52 +0000 (11:31 +0000)
2011-04-21  Richard Guenther  <rguenther@suse.de>

* tree-ssa-alias.c (ref_maybe_used_by_stmt_p): Handle
return statements.

From-SVN: r172820

gcc/ChangeLog
gcc/tree-ssa-alias.c

index a581d7a0ca1cc0ff455e7a99fb3960bd079c0042..a414107f799fe69a4fa6e2322b4ba9094f58bd66 100644 (file)
@@ -1,3 +1,8 @@
+2011-04-21  Richard Guenther  <rguenther@suse.de>
+
+       * tree-ssa-alias.c (ref_maybe_used_by_stmt_p): Handle
+       return statements.
+
 2011-04-21  Joseph Myers  <joseph@codesourcery.com>
 
        * config/i386/cygming.h (union tree_node, TREE): Don't define or
index a77c803b98c08ed9fafd2f3fffbde81732aad227..673073ee81a5f1c572e8a1ec79e8541b653f597a 100644 (file)
@@ -1364,6 +1364,26 @@ ref_maybe_used_by_stmt_p (gimple stmt, tree ref)
     }
   else if (is_gimple_call (stmt))
     return ref_maybe_used_by_call_p (stmt, ref);
+  else if (gimple_code (stmt) == GIMPLE_RETURN)
+    {
+      tree retval = gimple_return_retval (stmt);
+      tree base;
+      if (retval
+         && TREE_CODE (retval) != SSA_NAME
+         && !is_gimple_min_invariant (retval)
+         && refs_may_alias_p (retval, ref))
+       return true;
+      /* If ref escapes the function then the return acts as a use.  */
+      base = get_base_address (ref);
+      if (!base)
+       ;
+      else if (DECL_P (base))
+       return is_global_var (base);
+      else if (TREE_CODE (base) == MEM_REF
+              || TREE_CODE (base) == TARGET_MEM_REF)
+       return ptr_deref_may_alias_global_p (TREE_OPERAND (base, 0));
+      return false;
+    }
 
   return true;
 }