re PR tree-optimization/20076 (__builtin_return(__builtin_apply()) inlined incorrectly)
authorJakub Jelinek <jakub@redhat.com>
Tue, 5 Apr 2005 20:10:13 +0000 (22:10 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 5 Apr 2005 20:10:13 +0000 (22:10 +0200)
PR tree-optimization/20076
* tree-inline.c (inline_forbidden_p_1): Prevent inlining functions
that call __builtin_return or __builtin_apply_args.

* gcc.dg/builtin-apply4.c: New test.

From-SVN: r97653

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/builtin-apply4.c [new file with mode: 0644]
gcc/tree-inline.c

index 8b51e091efe37884f98748412279c846eea4d166..f9034674f747f6f952b9f99fc0fb0710700eb4a5 100644 (file)
@@ -1,3 +1,9 @@
+2005-04-05  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/20076
+       * tree-inline.c (inline_forbidden_p_1): Prevent inlining functions
+       that call __builtin_return or __builtin_apply_args.
+
 2005-04-05  Andrew MacLeod  <amacleod@redhat.com>
 
        * lambda-code.c (lambda_loopnest_to_gcc_loopnest): Use update_stmt.
index e9a68b3e8503b2e5d7fd19fe0d043233bce639bb..79bfe2300b56e3811cd5b257d97b0df7dde64ad5 100644 (file)
@@ -1,5 +1,8 @@
 2005-04-05  Jakub Jelinek  <jakub@redhat.com>
 
+       PR tree-optimization/20076
+       * gcc.dg/builtin-apply4.c: New test.
+
        PR preprocessor/19475
        * gcc.dg/cpp/macspace1.c: New test.
        * gcc.dg/cpp/macspace2.c: New test.
diff --git a/gcc/testsuite/gcc.dg/builtin-apply4.c b/gcc/testsuite/gcc.dg/builtin-apply4.c
new file mode 100644 (file)
index 0000000..289694e
--- /dev/null
@@ -0,0 +1,30 @@
+/* PR tree-optimization/20076 */
+/* { dg-options "-O2" } */
+/* { dg-do run } */
+
+extern void abort (void);
+
+double
+foo (int arg)
+{
+  if (arg != 116)
+    abort();
+  return arg + 1;
+}
+
+inline double
+bar (int arg)
+{
+  foo (arg);
+  __builtin_return (__builtin_apply ((void (*) ()) foo,
+                                    __builtin_apply_args (), 16));
+}
+
+int
+main (int argc, char **argv)
+{
+  if (bar (116) != 117.0)
+    abort ();
+
+  return 0;
+}
index 59a2d7237c9f4909ff457a0a5206ef142ae0cdca..efa6e310e98010bfd6411efac691da02ff8e6e47 100644 (file)
@@ -1017,6 +1017,17 @@ inline_forbidden_p_1 (tree *nodep, int *walk_subtrees ATTRIBUTE_UNUSED,
                   "it uses non-local goto");
            return node;
 
+         case BUILT_IN_RETURN:
+         case BUILT_IN_APPLY_ARGS:
+           /* If a __builtin_apply_args caller would be inlined,
+              it would be saving arguments of the function it has
+              been inlined into.  Similarly __builtin_return would
+              return from the function the inline has been inlined into.  */
+           inline_forbidden_reason
+             = N_("%Jfunction %qF can never be inlined because "
+                  "it uses __builtin_return or __builtin_apply_args");
+           return node;
+
          default:
            break;
          }