summaryrefslogtreecommitdiff
path: root/gcc/explow.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2017-10-19 15:58:05 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2017-10-19 15:58:05 +0000
commit9e878cf1bae7eba3a097dbb6b04d0bbca5bdb0e4 (patch)
tree220024bc6525d567df9a66f538a7903a174bcadc /gcc/explow.c
parentd969783705f55506c111e4f4d0342b09ef301ea2 (diff)
downloadgcc-9e878cf1bae7eba3a097dbb6b04d0bbca5bdb0e4.tar.gz
asan.c (handle_builtin_alloca): Deal with all alloca variants.
* asan.c (handle_builtin_alloca): Deal with all alloca variants. (get_mem_refs_of_builtin_call): Likewise. * builtins.c (expand_builtin_apply): Adjust call to allocate_dynamic_stack_space. (expand_builtin_alloca): For __builtin_alloca_with_align_and_max, pass the third argument to allocate_dynamic_stack_space, otherwise -1. (expand_builtin): Deal with all alloca variants. (is_inexpensive_builtin): Likewise. * builtins.def (BUILT_IN_ALLOCA_WITH_ALIGN_AND_MAX): New. * calls.c (special_function_p): Deal with all alloca variants. (initialize_argument_information): Adjust call to allocate_dynamic_stack_space. (expand_call): Likewise. * cfgexpand.c (expand_call_stmt): Deal with all alloca variants. * doc/extend.texi (Built-ins): Add __builtin_alloca_with_align_and_max * explow.c (allocate_dynamic_stack_space): Add MAX_SIZE parameter and use it for the stack usage computation. * explow.h (allocate_dynamic_stack_space): Adjust prototype. * function.c (gimplify_parameters): Turn BUILT_IN_ALLOCA_WITH_ALIGN into BUILT_IN_ALLOCA_WITH_ALIGN_AND_MAX and pass maximum size. * gimple-ssa-warn-alloca.c (alloca_call_type): Simplify control flow. Take into account 3rd argument of __builtin_alloca_with_align_and_max. (in_loop_p): Remove first argument and useless check. (pass_walloca::execute): Remove useless test and adjust call to above. * gimple.c (gimple_build_call_from_tree): Deal with all alloc variants * gimplify.c (gimplify_vla_decl): Turn BUILT_IN_ALLOCA_WITH_ALIGN into BUILT_IN_ALLOCA_WITH_ALIGN_AND_MAX and pass maximum size. (gimplify_call_expr): Deal with all alloca variants. * hsa-gen.c (gen_hsa_alloca): Likewise. (gen_hsa_insns_for_call): Likewise. * ipa-pure-const.c (special_builtin_state): Likewise. * tree-chkp.c (chkp_build_returned_bound): Likewise. * tree-object-size.c (alloc_object_size): Likewise. * tree-ssa-alias.c (ref_maybe_used_by_call_p_1): Likewise. (call_may_clobber_ref_p_1): Likewise. * tree-ssa-ccp.c (evaluate_stmt): Likewise. (ccp_fold_stmt): Likewise. (optimize_stack_restore): Likewise. * tree-ssa-dce.c (mark_stmt_if_obviously_necessary): Likewise. (mark_all_reaching_defs_necessary_1): Likewise. (propagate_necessity): Likewise. (eliminate_unnecessary_stmts): Likewise. * tree.c (build_common_builtin_nodes): Build BUILT_IN_ALLOCA_WITH_ALIGN_AND_MAX. * tree.h (ALLOCA_FUNCTION_CODE_P): New macro. (CASE_BUILT_IN_ALLOCA): Likewise. * varasm.c (incorporeal_function_p): Deal with all alloca variants. c-family/ * c-common.c (check_builtin_function_arguments): Also check arguments of __builtin_alloca_with_align_and_max. From-SVN: r253901
Diffstat (limited to 'gcc/explow.c')
-rw-r--r--gcc/explow.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/gcc/explow.c b/gcc/explow.c
index 6131d1810cb..662865d2808 100644
--- a/gcc/explow.c
+++ b/gcc/explow.c
@@ -1322,6 +1322,9 @@ get_stack_check_protect (void)
REQUIRED_ALIGN is the alignment (in bits) required for the region
of memory.
+ MAX_SIZE is an upper bound for SIZE, if SIZE is not constant, or -1 if
+ no such upper bound is known.
+
If CANNOT_ACCUMULATE is set to TRUE, the caller guarantees that the
stack space allocated by the generated code cannot be added with itself
in the course of the execution of the function. It is always safe to
@@ -1331,7 +1334,9 @@ get_stack_check_protect (void)
rtx
allocate_dynamic_stack_space (rtx size, unsigned size_align,
- unsigned required_align, bool cannot_accumulate)
+ unsigned required_align,
+ HOST_WIDE_INT max_size,
+ bool cannot_accumulate)
{
HOST_WIDE_INT stack_usage_size = -1;
rtx_code_label *final_label;
@@ -1370,8 +1375,12 @@ allocate_dynamic_stack_space (rtx size, unsigned size_align,
}
}
- /* If the size is not constant, we can't say anything. */
- if (stack_usage_size == -1)
+ /* If the size is not constant, try the maximum size. */
+ if (stack_usage_size < 0)
+ stack_usage_size = max_size;
+
+ /* If the size is still not constant, we can't say anything. */
+ if (stack_usage_size < 0)
{
current_function_has_unbounded_dynamic_stack_size = 1;
stack_usage_size = 0;