summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2004-01-13 02:35:27 +0100
committerJan Hubicka <hubicka@gcc.gnu.org>2004-01-13 01:35:27 +0000
commit2d3270129fac84d3d3420a1da10330404ccadc2a (patch)
tree45863b0867b1a5dca9004db917fa2c41f48f77a5
parent04cc79bb8928ff2c97bef9df08dc252eecdc9845 (diff)
downloadgcc-2d3270129fac84d3d3420a1da10330404ccadc2a.tar.gz
cgraphunit.c (cgraph_optimize_function): Always do optimize_inline_calls when there is always_inline callee.
* 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
-rw-r--r--gcc/ChangeLog10
-rw-r--r--gcc/cgraphunit.c13
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/always_inline.c21
-rw-r--r--gcc/testsuite/gcc.dg/debug/20031231-1.c1
-rw-r--r--gcc/toplev.h2
-rw-r--r--gcc/tree-inline.c16
7 files changed, 57 insertions, 11 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index d237ad9d612..a162c76c877 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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
diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index 8b17d3e7b65..cf7069b1b08 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -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;
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 4785a3d6f4b..2e48b756259 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 00000000000..9480470a95a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/always_inline.c
@@ -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);
+}
diff --git a/gcc/testsuite/gcc.dg/debug/20031231-1.c b/gcc/testsuite/gcc.dg/debug/20031231-1.c
index 08e7ac49d7f..fa20260b50e 100644
--- a/gcc/testsuite/gcc.dg/debug/20031231-1.c
+++ b/gcc/testsuite/gcc.dg/debug/20031231-1.c
@@ -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
diff --git a/gcc/toplev.h b/gcc/toplev.h
index 31611c3a220..3c1a1eb3021 100644
--- a/gcc/toplev.h
+++ b/gcc/toplev.h
@@ -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);
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 9d73be287ba..ea8edcf70dc 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -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");