- return 0;
-
- /* Assume it is not inlinable. */
- inlinable = 0;
-
- /* The number of instructions (estimated) of current function. */
- currfn_insns = DECL_NUM_STMTS (fn) * INSNS_PER_STMT;
-
- /* If we're not inlining things, then nothing is inlinable. */
- if (! flag_inline_trees)
- ;
- /* 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
- front-end that must set DECL_INLINE in this case, because
- dwarf2out loses if a function is inlined that doesn't have
- DECL_INLINE set. */
- else if (! DECL_INLINE (fn))
- ;
- /* We can't inline functions that are too big. Only allow a single
- function to be of MAX_INLINE_INSNS_SINGLE size. Make special
- allowance for extern inline functions, though. */
- else if (! (*lang_hooks.tree_inlining.disregard_inline_limits) (fn)
- && currfn_insns > MAX_INLINE_INSNS_SINGLE)
- ;
- /* 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;
+ 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);
+
+ /* 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
+ forward declared inline functions. Therefore, return at once. */
+ if (!DECL_SAVED_TREE (fn))
+ return false;
+
+ /* If we're not inlining at all, then we cannot inline this function. */
+ else if (!flag_inline_trees)
+ inlinable = false;
+
+ /* Only try to inline functions if DECL_INLINE is set. This should be
+ true for all functions declared `inline', and for all other functions
+ as well with -finline-functions.
+
+ Don't think of disregarding DECL_INLINE when flag_inline_trees == 2;
+ it's the front-end that must set DECL_INLINE in this case, because
+ dwarf2out loses if a function that does not have DECL_INLINE set is
+ inlined anyway. That is why we have both DECL_INLINE and
+ DECL_DECLARED_INLINE_P. */
+ /* FIXME: When flag_inline_trees dies, the check for flag_unit_at_a_time
+ here should be redundant. */
+ else if (!DECL_INLINE (fn) && !flag_unit_at_a_time)
+ inlinable = false;
+
+#ifdef INLINER_FOR_JAVA
+ /* Synchronized methods can't be inlined. This is a bug. */
+ else if (METHOD_SYNCHRONIZED (fn))
+ inlinable = false;
+#endif /* INLINER_FOR_JAVA */
+
+ /* We can't inline functions that call __builtin_longjmp at all.
+ The non-local goto machinery really requires the destination
+ be in a different function. If we allow the function calling
+ __builtin_longjmp to be inlined into the function calling
+ __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)))
+ calls_builtin_longjmp = true;
+
+ /* 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)))
+ calls_alloca = true;
+
+ if (calls_builtin_longjmp || calls_alloca)
+ {
+ /* See if we should warn about uninlinable functions. Previously,
+ some of these warnings would be issued while trying to expand
+ the function inline, but that would cause multiple warnings
+ 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 (do_warning && calls_builtin_longjmp)
+ warning ("%Hfunction '%F' can never be inlined because it uses "
+ "setjmp-longjmp exception handling",
+ &DECL_SOURCE_LOCATION (fn), fn);
+ if (do_warning && calls_alloca)
+ warning ("%Hfunction '%F' can never be inlined because it uses "
+ "setjmp-longjmp exception handling",
+ &DECL_SOURCE_LOCATION (fn), fn);
+
+ inlinable = false;
+ }