summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2017-02-11 17:56:02 +0000
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2017-02-11 17:56:02 +0000
commit29b884ae5bc0aa07dc5aca2959961becf7ad215e (patch)
tree0efc3420ad98c534a5761346fa3b54636f7219b0
parent71d4cbd29911bf15c1ac15499e6be461935777a1 (diff)
downloadgcc-29b884ae5bc0aa07dc5aca2959961becf7ad215e.tar.gz
PR tree-ssa/56727
* gcc.dg/tree-ssa/pr56727.c: New testcase. * ipa-utils.c (recursive_call_p): Be more careful about interposition. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@245359 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/ipa-utils.c18
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr56727.c16
4 files changed, 42 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 424fb4f6f29..969fccfe9ee 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,10 @@
2017-02-11 Jan Hubicka <hubicka@ucw.cz>
+ PR tree-ssa/56727
+ * gcc.dg/tree-ssa/pr56727.c: New testcase.
+
+2017-02-11 Jan Hubicka <hubicka@ucw.cz>
+
PR ipa/79224
* ipa-inline-analysis.c (get_minimal_bb): New function.
(record_modified): Use it.
diff --git a/gcc/ipa-utils.c b/gcc/ipa-utils.c
index fc1ae1e19d1..98a4f11d9bf 100644
--- a/gcc/ipa-utils.c
+++ b/gcc/ipa-utils.c
@@ -639,6 +639,20 @@ recursive_call_p (tree func, tree dest)
{
struct cgraph_node *dest_node = cgraph_node::get_create (dest);
struct cgraph_node *cnode = cgraph_node::get_create (func);
-
- return dest_node->semantically_equivalent_p (cnode);
+ ipa_ref *alias;
+ enum availability avail;
+
+ gcc_assert (!cnode->alias);
+ if (cnode != dest_node->ultimate_alias_target (&avail))
+ return false;
+ if (avail >= AVAIL_AVAILABLE)
+ return true;
+ if (!dest_node->semantically_equivalent_p (cnode))
+ return false;
+ /* If there is only one way to call the fuction or we know all of them
+ are semantically equivalent, we still can consider call recursive. */
+ FOR_EACH_ALIAS (cnode, alias)
+ if (!dest_node->semantically_equivalent_p (alias->referring))
+ return false;
+ return true;
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 7a5abd8a333..a6afdf5d0a0 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2017-02-11 Jan Hubicka <hubicka@ucw.cz>
+
+ PR tree-ssa/56727
+ * gcc.dg/tree-ssa/pr56727.c: New testcase.
+
2017-02-10 Jakub Jelinek <jakub@redhat.com>
PR c++/79457
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr56727.c b/gcc/testsuite/gcc.dg/tree-ssa/pr56727.c
new file mode 100644
index 00000000000..eaf8b5c971d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr56727.c
@@ -0,0 +1,16 @@
+/* { dg-require-alias "" } */
+/* { dg-do compile { target fpic } } *
+/* { dg-options "-O2 -fPIC -fdump-tree-optimized" } */
+void do_not_optimize(int b)
+{
+ do_not_optimize(0);
+}
+void do_optimize(int b)
+{
+ do_optimize(0);
+}
+
+void g(int b) __attribute__((alias(("do_not_optimize"))));
+
+/* { dg-final { scan-tree-dump "do_not_optimize .0" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "do_optimize .0" "optimized" } } */