From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1851) id 7D26C389680F; Fri, 20 Aug 2021 13:32:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7D26C389680F Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Martin Liska To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/marxin/heads/PR101949-ipa-modref-indirect-call)] IPA: MODREF should skip EAF_* flags for indirect calls X-Act-Checkin: gcc X-Git-Author: Martin Liska X-Git-Refname: refs/users/marxin/heads/PR101949-ipa-modref-indirect-call X-Git-Oldrev: 57d875f095cb8d0fb3f48fd039025c17a8c3a853 X-Git-Newrev: 5f1a6d7e2e1eef344c50241a2e2f266ceedf655c Message-Id: <20210820133237.7D26C389680F@sourceware.org> Date: Fri, 20 Aug 2021 13:32:37 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Aug 2021 13:32:37 -0000 https://gcc.gnu.org/g:5f1a6d7e2e1eef344c50241a2e2f266ceedf655c commit 5f1a6d7e2e1eef344c50241a2e2f266ceedf655c Author: Martin Liska Date: Fri Aug 20 14:27:13 2021 +0200 IPA: MODREF should skip EAF_* flags for indirect calls 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 Diff: --- 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(+) 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 &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); else { int ecf_flags = gimple_call_flags (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); +}