diff options
author | Bernd Edlinger <bernd.edlinger@hotmail.de> | 2016-07-21 19:06:02 +0000 |
---|---|---|
committer | Bernd Edlinger <edlinger@gcc.gnu.org> | 2016-07-21 19:06:02 +0000 |
commit | 159e8ef0c6673f73ab33ba86dd13652dfdae342c (patch) | |
tree | ce852e8aeab3c5945be947a5e82a7a2fe2b2bca3 | |
parent | df26a50d0d0665879975138bfe4f05285b2fadae (diff) | |
download | gcc-159e8ef0c6673f73ab33ba86dd13652dfdae342c.zip gcc-159e8ef0c6673f73ab33ba86dd13652dfdae342c.tar.gz gcc-159e8ef0c6673f73ab33ba86dd13652dfdae342c.tar.bz2 |
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
-rw-r--r-- | gcc/ChangeLog | 11 | ||||
-rw-r--r-- | gcc/calls.c | 42 | ||||
-rw-r--r-- | gcc/calls.h | 1 | ||||
-rw-r--r-- | gcc/tree-inline.c | 2 |
4 files changed, 50 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f559e29..b5b24a0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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> * spellcheck-tree.c (best_macro_match::best_macro_match): diff --git a/gcc/calls.c b/gcc/calls.c index 587969f..bb954ef 100644 --- a/gcc/calls.c +++ b/gcc/calls.c @@ -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 -gimple_alloca_call_p (const gimple *stmt) +gimple_maybe_alloca_call_p (const gimple *stmt) { tree fndecl; @@ -634,7 +634,31 @@ gimple_alloca_call_p (const gimple *stmt) 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 alloca_call_p (const_tree exp) @@ -642,8 +666,16 @@ alloca_call_p (const_tree exp) tree fndecl; if (TREE_CODE (exp) == CALL_EXPR && (fndecl = get_callee_fndecl (exp)) - && (special_function_p (fndecl, 0) & ECF_MAY_BE_ALLOCA)) - return true; + && 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; } diff --git a/gcc/calls.h b/gcc/calls.h index c6cca5d..e144156 100644 --- a/gcc/calls.h +++ b/gcc/calls.h @@ -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 call_expr_flags (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 alloca_call_p (const_tree); extern bool must_pass_in_stack_var_size (machine_mode, const_tree); diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index ef58866..f2b4491 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -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 VLA objects as those can't cause unbounded growth (they're always 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)) && !lookup_attribute ("always_inline", DECL_ATTRIBUTES (fn))) { |