https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112653
--- Comment #12 from Richard Biener <rguenth at gcc dot gnu.org> ---
Hmm, r10-900-ged315c041f48f4 contained related work(?), but a typo(?):
@@ -4976,7 +5002,12 @@ find_func_aliases (struct function *fn, gimple *origt)
greturn *return_stmt = as_a <greturn *> (t);
fi = NULL;
if (!in_ipa_mode
- || !(fi = get_vi_for_tree (fn->decl)))
+ && SSA_VAR_P (gimple_return_retval (return_stmt)))
+ {
+ /* We handle simple returns by post-processing the solutions. */
+ ;
+ }
+ if (!(fi = get_vi_for_tree (fn->decl)))
make_escape_constraint (gimple_return_retval (return_stmt));
the 2nd 'if' should be an 'else if', otherwise the code is dead. It doesn't
really help the testcase since 'test2' is still marked escaped but 2nd
level points-to effects of making the var escaped would be not there.
So instead of full-blown tracking of return_escaped one could fix the above
(will test for negative impact separately ...) and then compute
return_escaped during post-processing only. But I first have to understand
the post-processing code.