aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-inline.c
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2007-08-24 09:44:04 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2007-08-24 09:44:04 +0000
commit18177c7e9bbdda7316b5a5fbb54737ba48757260 (patch)
tree5270dcc8ebfd36c501d57a40ccebba1e3b65b19e /gcc/tree-inline.c
parent9c219b9bb34eafa7d9f42e3ffc5e73f77e397a75 (diff)
downloadgcc-18177c7e9bbdda7316b5a5fbb54737ba48757260.zip
gcc-18177c7e9bbdda7316b5a5fbb54737ba48757260.tar.gz
gcc-18177c7e9bbdda7316b5a5fbb54737ba48757260.tar.bz2
Makefile.in (tree-inline.o): Add $(TARGET_H) and $(INTEGRATE_H) dependencies.
2007-08-24 Richard Guenther <rguenther@suse.de> * Makefile.in (tree-inline.o): Add $(TARGET_H) and $(INTEGRATE_H) dependencies. * c-objc-common.c (c_cannot_inline_tree_fn): Remove. * langhooks.c (lhd_tree_inlining_cannot_inline_tree_fn): Likewise. * tree-inline.c (inlinable_function_p): Fold in common parts of the cannot_inline_tree_fn langhook. * langhooks-def.h (lhd_tree_inlining_cannot_inline_tree_fn): Remove. (LANG_HOOKS_TREE_INLINING_CANNOT_INLINE_TREE_FN): Likewise. (LANG_HOOKS_TREE_INLINING_INITIALIZER): Remove initializer for cannot_inline_tree_fn langhook. * langhooks.h (struct lang_hooks_for_tree_inlining): Remove cannot_inline_tree_fn member. cp/ * tree.c (cp_cannot_inline_tree_fn): Remove. * cp-tree.h (cp_cannot_inline_tree_fn): Likewise. * cp-objcp-common.h (LANG_HOOKS_TREE_INLINING_CANNOT_INLINE_TREE_FN): Remove define. From-SVN: r127763
Diffstat (limited to 'gcc/tree-inline.c')
-rw-r--r--gcc/tree-inline.c50
1 files changed, 36 insertions, 14 deletions
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index a24f70d..2b7ab9e 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -51,6 +51,8 @@ along with GCC; see the file COPYING3. If not see
#include "ipa-prop.h"
#include "value-prof.h"
#include "tree-pass.h"
+#include "target.h"
+#include "integrate.h"
/* I'm not real happy about this, but we need to handle gimple and
non-gimple trees. */
@@ -1848,18 +1850,44 @@ static bool
inlinable_function_p (tree fn)
{
bool inlinable = true;
+ bool do_warning;
+ tree always_inline;
/* If we've already decided this function shouldn't be inlined,
there's no need to check again. */
if (DECL_UNINLINABLE (fn))
return false;
- /* See if there is any language-specific reason it cannot be
- inlined. (It is important that this hook be called early because
- in C++ it may result in template instantiation.)
- If the function is not inlinable for language-specific reasons,
- it is left up to the langhook to explain why. */
- inlinable = !lang_hooks.tree_inlining.cannot_inline_tree_fn (&fn);
+ /* We only warn for functions declared `inline' by the user. */
+ do_warning = (warn_inline
+ && DECL_INLINE (fn)
+ && DECL_DECLARED_INLINE_P (fn)
+ && !DECL_IN_SYSTEM_HEADER (fn));
+
+ always_inline = lookup_attribute ("always_inline", DECL_ATTRIBUTES (fn));
+
+ if (flag_really_no_inline
+ && always_inline == NULL)
+ {
+ if (do_warning)
+ warning (OPT_Winline, "function %q+F can never be inlined because it "
+ "is suppressed using -fno-inline", fn);
+ inlinable = false;
+ }
+
+ /* Don't auto-inline anything that might not be bound within
+ this unit of translation. */
+ else if (!DECL_DECLARED_INLINE_P (fn)
+ && DECL_REPLACEABLE_P (fn))
+ inlinable = false;
+
+ else if (!function_attribute_inlinable_p (fn))
+ {
+ if (do_warning)
+ warning (OPT_Winline, "function %q+F can never be inlined because it "
+ "uses attributes conflicting with inlining", fn);
+ inlinable = false;
+ }
/* If we don't have the function body available, we can't inline it.
However, this should not be recorded since we also get here for
@@ -1893,14 +1921,8 @@ inlinable_function_p (tree fn)
about functions that would for example call alloca. But since
this a property of the function, just one warning is enough.
As a bonus we can now give more details about the reason why a
- function is not inlinable.
- We only warn for functions declared `inline' by the user. */
- bool do_warning = (warn_inline
- && DECL_INLINE (fn)
- && DECL_DECLARED_INLINE_P (fn)
- && !DECL_IN_SYSTEM_HEADER (fn));
-
- if (lookup_attribute ("always_inline", DECL_ATTRIBUTES (fn)))
+ function is not inlinable. */
+ if (always_inline)
sorry (inline_forbidden_reason, fn);
else if (do_warning)
warning (OPT_Winline, inline_forbidden_reason, fn);