]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR tree-optimization/84739 (ICE in get_value_for_expr, at tree-ssa-ccp...
authorJakub Jelinek <jakub@redhat.com>
Fri, 22 Jun 2018 20:31:10 +0000 (22:31 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 22 Jun 2018 20:31:10 +0000 (22:31 +0200)
Backported from mainline
2018-03-08  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/84739
* tree-tailcall.c (find_tail_calls): Check call arguments against
DECL_ARGUMENTS (current_function_decl) rather than
DECL_ARGUMENTS (func) when checking for tail recursion.

* gcc.dg/pr84739.c: New test.

From-SVN: r261914

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr84739.c [new file with mode: 0644]
gcc/tree-tailcall.c

index 7e1744f500f4367cd8e4eb018c66257523cdfac9..89485229092ec2601c80120021049b7a1afbadfd 100644 (file)
@@ -1,6 +1,13 @@
 2018-06-22  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2018-03-08  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/84739
+       * tree-tailcall.c (find_tail_calls): Check call arguments against
+       DECL_ARGUMENTS (current_function_decl) rather than
+       DECL_ARGUMENTS (func) when checking for tail recursion.
+
        2018-03-05  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/84700
index cc106e7fb55bc4e41be83fb66a45806d57975d81..98a4db6feddd43ed2cf6e9ac07dccceafee9ec02 100644 (file)
@@ -1,6 +1,11 @@
 2018-06-22  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2018-03-08  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/84739
+       * gcc.dg/pr84739.c: New test.
+
        2018-03-05  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/84700
diff --git a/gcc/testsuite/gcc.dg/pr84739.c b/gcc/testsuite/gcc.dg/pr84739.c
new file mode 100644 (file)
index 0000000..9864f99
--- /dev/null
@@ -0,0 +1,26 @@
+/* PR tree-optimization/84739 */
+/* { dg-do compile } */
+/* { dg-require-weak "" } */
+/* { dg-options "-O2 -w" } */
+
+static void baz (void) __attribute__((weakref("bar")));
+
+int
+foo (int x, int y)
+{
+  if (x)
+    y = 0;
+  if (y)
+    goto lab;
+  y = 0;
+lab:
+  return y;
+}
+
+void
+bar (int x, int y)
+{
+  y = foo (x, y);
+  if (y != 0)
+    baz ();
+}
index f586edcd730ffb702b5f7692f2939d25708cb2b6..ed443fa0883592d663970a32f0a6d1ac990f4f9f 100644 (file)
@@ -473,7 +473,7 @@ find_tail_calls (basic_block bb, struct tailcall **ret)
     {
       tree arg;
 
-      for (param = DECL_ARGUMENTS (func), idx = 0;
+      for (param = DECL_ARGUMENTS (current_function_decl), idx = 0;
           param && idx < gimple_call_num_args (call);
           param = DECL_CHAIN (param), idx ++)
        {