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 <rguent...@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; }