https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104303
--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> --- Btw, ref_may_access_global_memory_p already checks if (!auto_var_in_fn_p (base, current_function_decl) || pt_solution_includes (&cfun->gimple_df->escaped, base)) so it seems it was aware of some issue. I'm testing some patch.