]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Use modref even for nested functions in ref_maybe_used_by_call_p_1
authorJan Hubicka <jh@suse.cz>
Fri, 19 Nov 2021 17:09:13 +0000 (18:09 +0100)
committerJan Hubicka <jh@suse.cz>
Fri, 19 Nov 2021 17:09:13 +0000 (18:09 +0100)
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  <hubicka@ucw.cz>

* 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  <hubicka@ucw.cz>

* gcc.dg/tree-ssa/modref-dse-6.c: New test.

gcc/testsuite/gcc.dg/tree-ssa/modref-dse-6.c [new file with mode: 0644]
gcc/tree-ssa-alias.c

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 (file)
index 0000000..d1e45a8
--- /dev/null
@@ -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" } } */
index 02bbc87b5973b3afc21bcac9d96c96159d3234e7..cd6a0b2f67ba5c7343ca0369629d03f8f5625f5e 100644 (file)
@@ -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