016-07-21 Bernd Edlinger <bernd.edlinger@hotmail.de>

PR middle-end/71876
        * calls.c (gimple_maybe_alloca_call_p): New function.  Return true
        if STMT may be an alloca call.
        (gimple_alloca_call_p, alloca_call_p): Return only true for the
        builtin alloca call.
        * calls.h (gimple_maybe_alloca_call_p): New function.
        * tree-inline.c (inline_forbidden_p_stmt): Use
        gimple_maybe_alloca_call_p here.

From-SVN: r238605
This commit is contained in:
Bernd Edlinger 2016-07-21 19:06:02 +00:00 committed by Bernd Edlinger
parent df26a50d0d
commit 159e8ef0c6
4 changed files with 50 additions and 6 deletions

View File

@ -1,3 +1,14 @@
2016-07-21 Bernd Edlinger <bernd.edlinger@hotmail.de>
PR middle-end/71876
* calls.c (gimple_maybe_alloca_call_p): New function. Return true
if STMT may be an alloca call.
(gimple_alloca_call_p, alloca_call_p): Return only true for the
builtin alloca call.
* calls.h (gimple_maybe_alloca_call_p): New function.
* tree-inline.c (inline_forbidden_p_stmt): Use
gimple_maybe_alloca_call_p here.
2016-07-21 David Malcolm <dmalcolm@redhat.com> 2016-07-21 David Malcolm <dmalcolm@redhat.com>
* spellcheck-tree.c (best_macro_match::best_macro_match): * spellcheck-tree.c (best_macro_match::best_macro_match):

View File

@ -617,10 +617,10 @@ setjmp_call_p (const_tree fndecl)
} }
/* Return true if STMT is an alloca call. */ /* Return true if STMT may be an alloca call. */
bool bool
gimple_alloca_call_p (const gimple *stmt) gimple_maybe_alloca_call_p (const gimple *stmt)
{ {
tree fndecl; tree fndecl;
@ -634,7 +634,31 @@ gimple_alloca_call_p (const gimple *stmt)
return false; return false;
} }
/* Return true when exp contains alloca call. */ /* Return true if STMT is a builtin alloca call. */
bool
gimple_alloca_call_p (const gimple *stmt)
{
tree fndecl;
if (!is_gimple_call (stmt))
return false;
fndecl = gimple_call_fndecl (stmt);
if (fndecl && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL)
switch (DECL_FUNCTION_CODE (fndecl))
{
case BUILT_IN_ALLOCA:
case BUILT_IN_ALLOCA_WITH_ALIGN:
return true;
default:
break;
}
return false;
}
/* Return true when exp contains a builtin alloca call. */
bool bool
alloca_call_p (const_tree exp) alloca_call_p (const_tree exp)
@ -642,8 +666,16 @@ alloca_call_p (const_tree exp)
tree fndecl; tree fndecl;
if (TREE_CODE (exp) == CALL_EXPR if (TREE_CODE (exp) == CALL_EXPR
&& (fndecl = get_callee_fndecl (exp)) && (fndecl = get_callee_fndecl (exp))
&& (special_function_p (fndecl, 0) & ECF_MAY_BE_ALLOCA)) && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL)
return true; switch (DECL_FUNCTION_CODE (fndecl))
{
case BUILT_IN_ALLOCA:
case BUILT_IN_ALLOCA_WITH_ALIGN:
return true;
default:
break;
}
return false; return false;
} }

View File

@ -23,6 +23,7 @@ along with GCC; see the file COPYING3. If not see
extern int flags_from_decl_or_type (const_tree); extern int flags_from_decl_or_type (const_tree);
extern int call_expr_flags (const_tree); extern int call_expr_flags (const_tree);
extern int setjmp_call_p (const_tree); extern int setjmp_call_p (const_tree);
extern bool gimple_maybe_alloca_call_p (const gimple *);
extern bool gimple_alloca_call_p (const gimple *); extern bool gimple_alloca_call_p (const gimple *);
extern bool alloca_call_p (const_tree); extern bool alloca_call_p (const_tree);
extern bool must_pass_in_stack_var_size (machine_mode, const_tree); extern bool must_pass_in_stack_var_size (machine_mode, const_tree);

View File

@ -3577,7 +3577,7 @@ inline_forbidden_p_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p,
RAM instead of 256MB. Don't do so for alloca calls emitted for RAM instead of 256MB. Don't do so for alloca calls emitted for
VLA objects as those can't cause unbounded growth (they're always VLA objects as those can't cause unbounded growth (they're always
wrapped inside stack_save/stack_restore regions. */ wrapped inside stack_save/stack_restore regions. */
if (gimple_alloca_call_p (stmt) if (gimple_maybe_alloca_call_p (stmt)
&& !gimple_call_alloca_for_var_p (as_a <gcall *> (stmt)) && !gimple_call_alloca_for_var_p (as_a <gcall *> (stmt))
&& !lookup_attribute ("always_inline", DECL_ATTRIBUTES (fn))) && !lookup_attribute ("always_inline", DECL_ATTRIBUTES (fn)))
{ {