Index: fortran/trans-decl.c =================================================================== --- fortran/trans-decl.c (revision 109033) +++ fortran/trans-decl.c (working copy) @@ -447,6 +447,7 @@ gfc_finish_decl (tree decl, tree init) } +static GTY(()) tree noescape_attribute = NULL_TREE; /* Apply symbol attributes to a variable, and add it to the function scope. */ @@ -457,13 +458,26 @@ gfc_finish_var_decl (tree decl, gfc_symb This is the equivalent of the TARGET variables. We also need to set this if the variable is passed by reference in a CALL statement. */ - + /* Set DECL_VALUE_EXPR for Cray Pointees. */ if (sym->attr.cray_pointee) gfc_finish_cray_pointee (decl, sym); if (sym->attr.target) TREE_ADDRESSABLE (decl) = 1; + + /* Add the attribute to tell the middle-end this variable can never + escape. */ + if (!sym->attr.target && !sym->attr.cray_pointee) + { + if (noescape_attribute == NULL_TREE) + { + tree noescape = get_identifier ("no escape"); + noescape_attribute = build_tree_list (noescape, NULL_TREE); + } + DECL_ATTRIBUTES (decl) = noescape_attribute; + } + /* If it wasn't used we wouldn't be getting it. */ TREE_USED (decl) = 1; Index: tree-ssa-structalias.c =================================================================== --- tree-ssa-structalias.c (revision 109033) +++ tree-ssa-structalias.c (working copy) @@ -2965,7 +2965,11 @@ update_alias_info (tree stmt, struct ali unsigned i; EXECUTE_IF_SET_IN_BITMAP (addr_taken, 0, i, bi) - mark_call_clobbered (referenced_var (i)); + { + tree decl = referenced_var (i); + if (!lookup_attribute ("no escape", DECL_ATTRIBUTES (decl))) + mark_call_clobbered (decl); + } } }