public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Handle returns in ref_maybe_used_by_stmt_p
@ 2011-04-21 12:20 Richard Guenther
  0 siblings, 0 replies; only message in thread
From: Richard Guenther @ 2011-04-21 12:20 UTC (permalink / raw)
  To: gcc-patches


With all returns now having virtual operands we can trivially arrive
at them during alias walks.  Instead of always returning true as we
did sofar this patch makes us more precise, also handle the fact
that a function return implicitly is a use for all values that
escape (now, hopefully I will get to the point to compute and store
separate points-to sets for variables that escape through function
returns ...).

This makes PR48702 be also exposed on trunk.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.

Richard.

2011-04-20  Richard Guenther  <rguenther@suse.de>

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

Index: gcc/tree-ssa-alias.c
===================================================================
*** gcc/tree-ssa-alias.c	(revision 172773)
--- gcc/tree-ssa-alias.c	(working copy)
*************** ref_maybe_used_by_stmt_p (gimple stmt, t
*** 1364,1369 ****
--- 1364,1389 ----
      }
    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;
  }

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

only message in thread, other threads:[~2011-04-21 11:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-21 12:20 [PATCH] Handle returns in ref_maybe_used_by_stmt_p Richard Guenther

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