diff options
Diffstat (limited to 'gcc/tree-ssa-alias.c')
-rw-r--r-- | gcc/tree-ssa-alias.c | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c index 4f66154..1523aeb 100644 --- a/gcc/tree-ssa-alias.c +++ b/gcc/tree-ssa-alias.c @@ -545,8 +545,14 @@ set_initial_properties (struct alias_info *ai) { struct ptr_info_def *pi = SSA_NAME_PTR_INFO (ptr); tree tag = symbol_mem_tag (SSA_NAME_VAR (ptr)); - - if (pi->value_escapes_p) + + /* A pointer that only escapes via a function return does not + add to the call clobber or call used solution. + To exclude ESCAPE_TO_PURE_CONST we would need to track + call used variables separately or compute those properly + in the operand scanner. */ + if (pi->value_escapes_p + && pi->escape_mask & ~ESCAPE_TO_RETURN) { /* If PTR escapes then its associated memory tags and pointed-to variables are call-clobbered. */ @@ -556,24 +562,13 @@ set_initial_properties (struct alias_info *ai) if (tag) mark_call_clobbered (tag, pi->escape_mask); - if (pi->pt_vars) - { - bitmap_iterator bi; - unsigned int j; - EXECUTE_IF_SET_IN_BITMAP (pi->pt_vars, 0, j, bi) - { - tree alias = referenced_var (j); - - /* If you clobber one part of a structure, you - clobber the entire thing. While this does not make - the world a particularly nice place, it is necessary - in order to allow C/C++ tricks that involve - pointer arithmetic to work. */ - if (!unmodifiable_var_p (alias)) - mark_call_clobbered (alias, pi->escape_mask); - } - } - else if (pi->pt_anything) + /* Defer to points-to analysis if possible, otherwise + clobber all addressable variables. Parameters cannot + point to local memory though. + ??? Properly tracking which pointers point to non-local + memory only would make a big difference here. */ + if (!clobber_what_p_points_to (ptr) + && !(pi->escape_mask & ESCAPE_IS_PARM)) { any_pt_anything = true; pt_anything_mask |= pi->escape_mask; |