diff options
author | Mark Mitchell <mark@codesourcery.com> | 2003-06-10 07:19:57 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 2003-06-10 07:19:57 +0000 |
commit | d58b7c2d5dec4e603b4eb740b4d7b2ce17cc6ce1 (patch) | |
tree | 99bd6c6f94bdf41422f8f7a377f59d5cb319ff5c /gcc/tree-inline.c | |
parent | c566f9bd367cf07de6e9151dd5a5882241b367bf (diff) | |
download | gcc-d58b7c2d5dec4e603b4eb740b4d7b2ce17cc6ce1.zip gcc-d58b7c2d5dec4e603b4eb740b4d7b2ce17cc6ce1.tar.gz gcc-d58b7c2d5dec4e603b4eb740b4d7b2ce17cc6ce1.tar.bz2 |
re PR c++/11131 (Unrelated declaration removes inline flag from function)
PR c++/11131
* tree-inline.c (inlinable_function_p): Call the language-specific
hook early.
PR c++/11131
* cp-tree.h (template_for_substitution): Declare.
* decl2.c (mark_used): Use it when figuring out whether or not a
function is inline.
* pt.c (template_for_substitution): Give it external linkage.
* tree.c (cp_cannot_inline_tree_fn): Instantiate as early as
possible.
PR c++/11131
* g++.dg/opt/template1.C: New test.
From-SVN: r67698
Diffstat (limited to 'gcc/tree-inline.c')
-rw-r--r-- | gcc/tree-inline.c | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index a0fbe8e..dd50ca1 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -979,8 +979,10 @@ inlinable_function_p (fn, id, nolimit) if (DECL_UNINLINABLE (fn)) return 0; - /* Assume it is not inlinable. */ - inlinable = 0; + /* 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.) */ + inlinable = !(*lang_hooks.tree_inlining.cannot_inline_tree_fn) (&fn); /* We may be here either because fn is declared inline or because we use -finline-functions. For the second case, we are more @@ -993,7 +995,7 @@ inlinable_function_p (fn, id, nolimit) /* If we're not inlining things, then nothing is inlinable. */ if (! flag_inline_trees) - ; + inlinable = 0; /* If we're not inlining all functions and the function was not declared `inline', we don't inline it. Don't think of disregarding DECL_INLINE when flag_inline_trees == 2; it's the @@ -1001,11 +1003,11 @@ inlinable_function_p (fn, id, nolimit) dwarf2out loses if a function is inlined that doesn't have DECL_INLINE set. */ else if (! DECL_INLINE (fn) && !nolimit) - ; + inlinable = 0; #ifdef INLINER_FOR_JAVA /* Synchronized methods can't be inlined. This is a bug. */ else if (METHOD_SYNCHRONIZED (fn)) - ; + inlinable = 0; #endif /* INLINER_FOR_JAVA */ /* We can't inline functions that are too big. Only allow a single function to be of MAX_INLINE_INSNS_SINGLE size. Make special @@ -1013,7 +1015,7 @@ inlinable_function_p (fn, id, nolimit) else if (!nolimit && ! (*lang_hooks.tree_inlining.disregard_inline_limits) (fn) && currfn_insns > max_inline_insns_single) - ; + inlinable = 0; /* We can't inline functions that call __builtin_longjmp at all. The non-local goto machenery really requires the destination be in a different function. If we allow the function calling @@ -1021,20 +1023,14 @@ inlinable_function_p (fn, id, nolimit) __builtin_setjmp, Things will Go Awry. */ /* ??? Need front end help to identify "regular" non-local goto. */ else if (find_builtin_longjmp_call (DECL_SAVED_TREE (fn))) - ; + inlinable = 0; /* Refuse to inline alloca call unless user explicitly forced so as this may change program's memory overhead drastically when the function using alloca is called in loop. In GCC present in SPEC2000 inlining into schedule_block cause it to require 2GB of ram instead of 256MB. */ else if (lookup_attribute ("always_inline", DECL_ATTRIBUTES (fn)) == NULL && find_alloca_call (DECL_SAVED_TREE (fn))) - ; - /* All is well. We can inline this function. Traditionally, GCC - has refused to inline functions using alloca, or functions whose - values are returned in a PARALLEL, and a few other such obscure - conditions. We are not equally constrained at the tree level. */ - else - inlinable = 1; + inlinable = 0; /* Squirrel away the result so that we don't have to check again. */ DECL_UNINLINABLE (fn) = ! inlinable; @@ -1065,9 +1061,6 @@ inlinable_function_p (fn, id, nolimit) } } - if (inlinable && (*lang_hooks.tree_inlining.cannot_inline_tree_fn) (&fn)) - inlinable = 0; - /* If we don't have the function body available, we can't inline it. */ if (! DECL_SAVED_TREE (fn)) |