https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103266
--- Comment #4 from rguenther at suse dot de <rguenther at suse dot de> --- On Mon, 15 Nov 2021, hubicka at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103266 > > Jan Hubicka <hubicka at gcc dot gnu.org> changed: > > What |Removed |Added > ---------------------------------------------------------------------------- > CC| |rguenther at suse dot de > > --- Comment #2 from Jan Hubicka <hubicka at gcc dot gnu.org> --- > Thanks for a nice testcase! > > We use "1cX " fnspec string_for assume aligned which indeed is problematic > since 'X' means that parameter is unused and thus we thus that it is not > returned. > "1" however specifies that function returns first parameter which is bit in a > contradiction with parameter being unused. PTA codes takes precedence to "1" > and thus works, while modref sees 'X' and ignore the parameters and thus > propagation breaks. > > In general we may have a specifier for pointer parameter that is used only as > a > scalar value and never read/written from. Perhaps 'S'? However I can also > teach modref to ignore unused for return handling. I think 'X' means simply not dereferenced or escaping since this was all PTA based. 'S' would still eventually allow escaping. But yes, PTA simply takes '1' literally. So the patch below is IMHO too pessimizing. Can you please fixup modref instead? > Following untesed patch should fix the issue > diff --git a/gcc/builtins.c b/gcc/builtins.c > index 7d0f61fc98b..baeaff6eb1f 100644 > --- a/gcc/builtins.c > +++ b/gcc/builtins.c > @@ -11101,7 +11101,7 @@ builtin_fnspec (tree callee) > case BUILT_IN_STACK_SAVE: > return ".c"; > case BUILT_IN_ASSUME_ALIGNED: > - return "1cX "; > + return "1cW "; > /* But posix_memalign stores a pointer into the memory pointed to > by its first argument. */ > case BUILT_IN_POSIX_MEMALIGN: > >