[PATCH] IPA: MODREF should skip EAF_* flags for indirect calls

Martin Jambor mjambor@suse.cz
Sat Aug 21 09:35:45 GMT 2021


Hi,

On Fri, Aug 20 2021, Martin Liška wrote:
> Hello.
>
> As showed in the PR, returning (EAF_NOCLOBBER | EAF_NOESCAPE) for an argument
> that is a function pointer is problematic. Doing such a function call is a clobber.
>
> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
>
> Ready to be installed?
> Thanks,
> Martin
>
> 	PR 101949
>
> gcc/ChangeLog:
>
> 	* ipa-modref.c (analyze_ssa_name_flags): Do not propagate EAF
> 	  flags arguments for indirect functions.
>
> gcc/testsuite/ChangeLog:
>
> 	* gcc.dg/lto/pr101949_0.c: New test.
> 	* gcc.dg/lto/pr101949_1.c: New test.
>
> Co-Authored-By: Richard Biener <rguenther@suse.de>
> ---
>   gcc/ipa-modref.c                      |  3 +++
>   gcc/testsuite/gcc.dg/lto/pr101949_0.c | 20 ++++++++++++++++++++
>   gcc/testsuite/gcc.dg/lto/pr101949_1.c |  4 ++++
>   3 files changed, 27 insertions(+)
>   create mode 100644 gcc/testsuite/gcc.dg/lto/pr101949_0.c
>   create mode 100644 gcc/testsuite/gcc.dg/lto/pr101949_1.c
>
> diff --git a/gcc/ipa-modref.c b/gcc/ipa-modref.c
> index fafd804d4ba..380ba6926b9 100644
> --- a/gcc/ipa-modref.c
> +++ b/gcc/ipa-modref.c
> @@ -1715,6 +1715,9 @@ analyze_ssa_name_flags (tree name, vec<modref_lattice> &lattice, int depth,
>   	  else if (callee && !ipa && recursive_call_p (current_function_decl,
>   						  callee))
>   	    lattice[index].merge (0);
> +	  /* Ignore indirect calls (PR101949).  */
> +	  else if (callee == NULL_TREE)
> +	    lattice[index].merge (0);

I just had a quick glance, but wouldn't bailing out only when

  gimple_call_fn (call) == name

suffice here?  Otherwise it seems to trigger also when passing NAME to
an indirectly called function about which we might learn something from
gimple_call_fntype, as the code apparently tries later on.

Martin



More information about the Gcc-patches mailing list