public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Martin Liska <marxin@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r11-8898] Clear EAF_NOCLOBBER for indirect calls Date: Tue, 24 Aug 2021 08:25:07 +0000 (GMT) [thread overview] Message-ID: <20210824082507.D64293858C2C@sourceware.org> (raw) https://gcc.gnu.org/g:d0adc557a26963b9ad0e07829872c968e67c5ffc commit r11-8898-gd0adc557a26963b9ad0e07829872c968e67c5ffc Author: Jan Hubicka <jh@suse.cz> Date: Sun Aug 22 20:57:19 2021 +0200 Clear EAF_NOCLOBBER for indirect calls gcc/ChangeLog: 2021-08-22 Jan Hubicka <hubicka@ucw.cz> Martin Liska <mliska@suse.cz> PR middle-end/101949 * ipa-modref.c (analyze_ssa_name_flags): Indirect call implies ~EAF_NOCLOBBER. gcc/testsuite/ChangeLog: 2021-08-22 Jan Hubicka <hubicka@ucw.cz> Martin Liska <mliska@suse.cz> * gcc.dg/lto/pr101949_0.c: New test. * gcc.dg/lto/pr101949_1.c: New test. (cherry picked from commit 9b08f7764cecd16cba84944f2a8b67a7f73a7ce7) Diff: --- gcc/ipa-modref.c | 9 +++++++++ gcc/testsuite/gcc.dg/lto/pr101949_0.c | 20 ++++++++++++++++++++ gcc/testsuite/gcc.dg/lto/pr101949_1.c | 4 ++++ 3 files changed, 33 insertions(+) diff --git a/gcc/ipa-modref.c b/gcc/ipa-modref.c index ef5e62beb0e..dc5ee8cc2d0 100644 --- a/gcc/ipa-modref.c +++ b/gcc/ipa-modref.c @@ -1621,6 +1621,15 @@ analyze_ssa_name_flags (tree name, vec<modref_lattice> &lattice, int depth, else if (gcall *call = dyn_cast <gcall *> (use_stmt)) { tree callee = gimple_call_fndecl (call); + + /* IPA PTA internally it treats calling a function as "writing" to + the argument space of all functions the function pointer points to + (PR101949). We can not drop EAF_NOCLOBBER only when ipa-pta + is on since that would allow propagation of this from -fno-ipa-pta + to -fipa-pta functions. */ + if (gimple_call_fn (use_stmt) == name) + lattice[index].merge (~EAF_NOCLOBBER); + /* Return slot optimization would require bit of propagation; give up for now. */ if (gimple_call_return_slot_opt_p (call) diff --git a/gcc/testsuite/gcc.dg/lto/pr101949_0.c b/gcc/testsuite/gcc.dg/lto/pr101949_0.c new file mode 100644 index 00000000000..142dffe8780 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/pr101949_0.c @@ -0,0 +1,20 @@ +/* { dg-lto-do run } */ +/* { dg-lto-options { "-O2 -fipa-pta -flto -flto-partition=1to1" } } */ + +extern int bar (int (*)(int *), int *); + +static int x; + +static int __attribute__ ((noinline)) foo (int *p) +{ + *p = 1; + x = 0; + return *p; +} + +int main () +{ + if (bar (foo, &x) != 0) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/lto/pr101949_1.c b/gcc/testsuite/gcc.dg/lto/pr101949_1.c new file mode 100644 index 00000000000..871d15c9bfb --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/pr101949_1.c @@ -0,0 +1,4 @@ +int __attribute__((noinline,noclone)) bar (int (*fn)(int *), int *p) +{ + return fn (p); +}
reply other threads:[~2021-08-24 8:25 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210824082507.D64293858C2C@sourceware.org \ --to=marxin@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).