cgraphunit.c (cgraph_optimize_function): Always do optimize_inline_calls when there...
authorJan Hubicka <jh@suse.cz>
Tue, 13 Jan 2004 01:35:27 +0000 (02:35 +0100)
committerJan Hubicka <hubicka@gcc.gnu.org>
Tue, 13 Jan 2004 01:35:27 +0000 (01:35 +0000)
* cgraphunit.c (cgraph_optimize_function):  Always do
optimize_inline_calls when there is always_inline callee.
(cgraph_decide_inlining): Fix formating.
* tree-inline.c (inlinable_function_p): Do sorry for alwaysinline
functions.
(expand_call_inline): Likewise.
* toplev.h (sorry): Fix prototype.

* gcc.dg/always_inline.c: New test.
* gcc.dg/debug/20031231-1.c: Fix.

From-SVN: r75781

gcc/ChangeLog
gcc/cgraphunit.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/always_inline.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/debug/20031231-1.c
gcc/toplev.h
gcc/tree-inline.c

index d237ad9d612942e0dfe09a3888546afec4fa2276..a162c76c8779c6b5175aca5318a3f80d7fa711df 100644 (file)
@@ -1,3 +1,13 @@
+2004-01-13  Jan Hubicka  <jh@suse.cz>
+
+       * cgraphunit.c (cgraph_optimize_function):  Always do
+       optimize_inline_calls when there is always_inline callee.
+       (cgraph_decide_inlining): Fix formating.
+       * tree-inline.c (inlinable_function_p): Do sorry for alwaysinline
+       functions.
+       (expand_call_inline): Likewise.
+       * toplev.h (sorry): Fix prototype.
+
 2004-01-12  Roger Sayle  <roger@eyesopen.com>
 
        * builtins.c (expand_builtin_expect_jump): Simplify logic. Handle
index 8b17d3e7b659d6e2277c70d6937f29bf0286b3e5..cf7069b1b08dfc48507a7194dfd7453385a5a3c1 100644 (file)
@@ -481,7 +481,10 @@ cgraph_optimize_function (struct cgraph_node *node)
       struct cgraph_edge *e;
 
       for (e = node->callees; e; e = e->next_callee)
-       if (!e->inline_failed || warn_inline)
+       if (!e->inline_failed || warn_inline
+           || (DECL_DECLARED_INLINE_P (e->callee->decl)
+               && lookup_attribute ("always_inline",
+                                    DECL_ATTRIBUTES (e->callee->decl))))
          break;
       if (e)
         optimize_inline_calls (decl);
@@ -1178,10 +1181,10 @@ cgraph_decide_inlining (void)
                     cgraph_node_name (node->callees->caller),
                     node->callees->caller->global.insns);
        }
-       if (cgraph_dump_file && node->global.cloned_times > 0)
-         fprintf (cgraph_dump_file, 
-                  " Inlined %i times for a net change of %+i insns.\n",
-                  node->global.cloned_times, overall_insns - old_insns);
+      if (cgraph_dump_file && node->global.cloned_times > 0)
+       fprintf (cgraph_dump_file, 
+                " Inlined %i times for a net change of %+i insns.\n",
+                node->global.cloned_times, overall_insns - old_insns);
       for (y = 0; y < ninlined; y++)
        inlined[y]->output = 0, node->aux = 0;
     }
index 4785a3d6f4b1b83061f6619568cc9ae17dd7d268..2e48b75625948e567516c92d92b466b3c1883aa1 100644 (file)
@@ -1,3 +1,8 @@
+2004-01-13  Jan Hubicka  <jh@suse.cz>
+
+       * gcc.dg/always_inline.c: New test.
+       * gcc.dg/debug/20031231-1.c: Fix.
+
 2004-01-13  Giovanni Bajo  <giovannibajo@gcc.gnu.org>
 
        PR c++/13474
diff --git a/gcc/testsuite/gcc.dg/always_inline.c b/gcc/testsuite/gcc.dg/always_inline.c
new file mode 100644 (file)
index 0000000..9480470
--- /dev/null
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options "-Winline -O2" } */
+#include <stdarg.h>
+inline __attribute__ ((always_inline)) void t(void); /* { dg-error "body not available" "" } */
+void
+q(void)
+{
+  t();                                 /* { dg-error "called from here" "" } */
+}
+inline __attribute__ ((always_inline)) void
+q2(void)
+{                              /* { dg-error "recursive" "" } */
+  q2();                        /* { dg-error "called from here" "" } */
+  q2();                        /* { dg-error "called from here" "" } */
+}
+inline __attribute__ ((always_inline)) void
+e(int t, ...)
+{                              /* { dg-error "variable argument" "" } */
+  va_list q;
+  va_start (q, t);
+}
index 08e7ac49d7fe4f8cd08c692a7bf877de05c00537..fa20260b50eaf4ad9d389bf8948ee1004638a4a6 100644 (file)
@@ -12,7 +12,6 @@ void pp_c_string_literal (c_pretty_printer *, tree);
 static __inline__  __attribute__((always_inline)) void
 pp_c_shift_expression (c_pretty_printer *pp, tree e)
 {
-        pp_c_shift_expression (pp,e);
 }
 
 static void
index 31611c3a2206d4a3ec87d828865d73f5899a8417..3c1a1eb3021c8612385735f96962423611c42744 100644 (file)
@@ -60,7 +60,7 @@ extern void error (const char *, ...);
 extern void fatal_error (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2)
      ATTRIBUTE_NORETURN;
 extern void pedwarn (const char *, ...);
-extern void sorry (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
+extern void sorry (const char *, ...);
 extern void inform (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
 
 extern void rest_of_decl_compilation (tree, const char *, int, int);
index 9d73be287ba68f6f51bd35b87c606afcbe78c49a..ea8edcf70dc11164f570449977498883c2f16340 100644 (file)
@@ -1213,7 +1213,10 @@ inlinable_function_p (tree fn)
                         && DECL_DECLARED_INLINE_P (fn)
                         && !DECL_IN_SYSTEM_HEADER (fn));
 
-      if (do_warning)
+      if (lookup_attribute ("always_inline",
+                           DECL_ATTRIBUTES (fn)))
+       sorry (inline_forbidden_reason, fn, fn);
+      else if (do_warning)
        warning (inline_forbidden_reason, fn, fn);
 
       inlinable = false;
@@ -1330,9 +1333,14 @@ expand_call_inline (tree *tp, int *walk_subtrees, void *data)
      inlining.  */
   if (!cgraph_inline_p (id->current_decl, fn, &reason))
     {
-      if (warn_inline && DECL_DECLARED_INLINE_P (fn)
-         && !DECL_IN_SYSTEM_HEADER (fn)
-         && strlen (reason))
+      if (lookup_attribute ("always_inline", DECL_ATTRIBUTES (fn)))
+       {
+         sorry ("%Jinlining failed in call to '%F': %s", fn, fn, reason);
+         sorry ("called from here");
+       }
+      else if (warn_inline && DECL_DECLARED_INLINE_P (fn)
+              && !DECL_IN_SYSTEM_HEADER (fn)
+              && strlen (reason))
        {
          warning ("%Jinlining failed in call to '%F': %s", fn, fn, reason);
          warning ("called from here");