From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1075) id 30677385BF9F; Fri, 19 Nov 2021 17:09:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 30677385BF9F MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jan Hubicka To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-5411] Use modref even for nested functions in ref_maybe_used_by_call_p_1 X-Act-Checkin: gcc X-Git-Author: Jan Hubicka X-Git-Refname: refs/heads/master X-Git-Oldrev: 16137fbb9256ef365dd498d39024eb33de1a4cd8 X-Git-Newrev: ada63d56beb0e535d35b165b55f85e29a0b36929 Message-Id: <20211119170951.30677385BF9F@sourceware.org> Date: Fri, 19 Nov 2021 17:09:51 +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, 19 Nov 2021 17:09:51 -0000 https://gcc.gnu.org/g:ada63d56beb0e535d35b165b55f85e29a0b36929 commit r12-5411-gada63d56beb0e535d35b165b55f85e29a0b36929 Author: Jan Hubicka Date: Fri Nov 19 18:09:13 2021 +0100 Use modref even for nested functions in ref_maybe_used_by_call_p_1 Remove test for function not having call chain guarding modref use in ref_maybe_used_by_call_p_1. It never made sense since modref treats call chain accesses explicitly. It was however copied from earlier check for ECF_CONST (which seems dubious too, but I would like to discuss it independelty). This enables us to detect that memory pointed to static chain (or parts of it) are unused by the function. lto-bootstrapped-regtested all lanugages on x86_64-linux. gcc/ChangeLog: 2021-11-19 Jan Hubicka * tree-ssa-alias.c (ref_maybe_used_by_call_p_1): Do not guard modref by !gimple_call_chain. gcc/testsuite/ChangeLog: 2021-11-19 Jan Hubicka * gcc.dg/tree-ssa/modref-dse-6.c: New test. Diff: --- gcc/testsuite/gcc.dg/tree-ssa/modref-dse-6.c | 23 +++++++++++++++++++++++ gcc/tree-ssa-alias.c | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/gcc/testsuite/gcc.dg/tree-ssa/modref-dse-6.c b/gcc/testsuite/gcc.dg/tree-ssa/modref-dse-6.c new file mode 100644 index 00000000000..d1e45a893ad --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/modref-dse-6.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +int +main() +{ + int a,b; + __attribute__ ((noinline)) + void kill_me() + { + a=1234; + b=2234; + } + a=0; + b=1234; + __attribute__ ((noinline)) + int reta() + { + return a; + } + return reta(); +} +/* { dg-final { scan-tree-dump-not "kill_me" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "1234" "optimized" } } */ diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c index 02bbc87b597..cd6a0b2f67b 100644 --- a/gcc/tree-ssa-alias.c +++ b/gcc/tree-ssa-alias.c @@ -2755,7 +2755,7 @@ ref_maybe_used_by_call_p_1 (gcall *call, ao_ref *ref, bool tbaa_p) callee = gimple_call_fndecl (call); - if (!gimple_call_chain (call) && callee != NULL_TREE) + if (callee != NULL_TREE) { struct cgraph_node *node = cgraph_node::get (callee); /* We can not safely optimize based on summary of calle if it does