https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105030
--- Comment #8 from rguenther at suse dot de <rguenther at suse dot de> --- On Fri, 25 Mar 2022, guihaoc at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105030 > > --- Comment #7 from HaoChen Gui <guihaoc at gcc dot gnu.org> --- > The original case comes from a Fortran program. I rewrote it with C. As the > arguments are passed by reference in Fortran (by default), the problem is > common. But I am not sure if it has a large performance impact. For the fortran case it probably helps to instead check the points-to escaped solution, so auto_var_in_fn_p (var, cfun) && !pt_solution_includes (&cfun->gimple_df->escaped, var) since the fortran frontend marks by reference passed as not escaping (unless they are POINTER or so, don't remember exactly). Note this isn't flow-sensitive so it doesn't help the C example you gave where the variable would be in the functions escaped set.