aboutsummaryrefslogtreecommitdiff
path: root/gcc/builtins.c
diff options
context:
space:
mode:
authorTom de Vries <tom@codesourcery.com>2011-10-07 12:49:49 +0000
committerTom de Vries <vries@gcc.gnu.org>2011-10-07 12:49:49 +0000
commit13e49da934e9ec80360817bc09c08be39aff479c (patch)
tree274fa9d31e31f79687aa8785b52bbd7532b95632 /gcc/builtins.c
parent764a2546bb1b7a4e3478042008ea75736de7c224 (diff)
downloadgcc-13e49da934e9ec80360817bc09c08be39aff479c.zip
gcc-13e49da934e9ec80360817bc09c08be39aff479c.tar.gz
gcc-13e49da934e9ec80360817bc09c08be39aff479c.tar.bz2
re PR middle-end/50527 (inconsistent vla align)
2011-10-07 Tom de Vries <tom@codesourcery.com> PR middle-end/50527 * tree.c (build_common_builtin_nodes): Add local_define_builtin for BUILT_IN_ALLOCA_WITH_ALIGN. Mark that BUILT_IN_ALLOCA_WITH_ALIGN can throw. * builtins.c (expand_builtin_alloca): Handle BUILT_IN_ALLOCA_WITH_ALIGN arglist. Set align for BUILT_IN_ALLOCA_WITH_ALIGN. (expand_builtin): Handle BUILT_IN_ALLOCA_WITH_ALIGN. (is_inexpensive_builtin): Handle BUILT_IN_ALLOCA_WITH_ALIGN. * tree-ssa-ccp.c (evaluate_stmt): Set align for BUILT_IN_ALLOCA_WITH_ALIGN. (fold_builtin_alloca_for_var): Rename to ... (fold_builtin_alloca_with_align): Set DECL_ALIGN from 2nd BUILT_IN_ALLOCA_WITH_ALIGN argument. (ccp_fold_stmt): Try folding BUILT_IN_ALLOCA_WITH_ALIGN using fold_builtin_alloca_with_align. (optimize_stack_restore): Handle BUILT_IN_ALLOCA_WITH_ALIGN. * builtins.def (BUILT_IN_ALLOCA_WITH_ALIGN): Declare using DEF_BUILTIN_STUB. * ipa-pure-const.c (special_builtin_state): Handle BUILT_IN_ALLOCA_WITH_ALIGN. * tree-ssa-alias.c (ref_maybe_used_by_call_p_1) (call_may_clobber_ref_p_1): Same. * function.c (gimplify_parameters): Lower vla to BUILT_IN_ALLOCA_WITH_ALIGN. * gimplify.c (gimplify_vla_decl): Same. * cfgexpand.c (expand_call_stmt): Handle BUILT_IN_ALLOCA_WITH_ALIGN. * tree-mudflap.c (mf_xform_statements): Same. * tree-ssa-dce.c (mark_stmt_if_obviously_necessary) (mark_all_reaching_defs_necessary_1, propagate_necessity): Same. * varasm.c (incorporeal_function_p): Same. * tree-object-size.c (alloc_object_size): Same. * gimple.c (gimple_build_call_from_tree): Same. From-SVN: r179655
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r--gcc/builtins.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c
index 8476b0e..bf1766a 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -4516,20 +4516,33 @@ expand_builtin_alloca (tree exp, bool cannot_accumulate)
{
rtx op0;
rtx result;
+ bool valid_arglist;
+ unsigned int align;
+ bool alloca_with_align = (DECL_FUNCTION_CODE (get_callee_fndecl (exp))
+ == BUILT_IN_ALLOCA_WITH_ALIGN);
/* Emit normal call if marked not-inlineable. */
if (CALL_CANNOT_INLINE_P (exp))
return NULL_RTX;
- if (!validate_arglist (exp, INTEGER_TYPE, VOID_TYPE))
+ valid_arglist
+ = (alloca_with_align
+ ? validate_arglist (exp, INTEGER_TYPE, INTEGER_TYPE, VOID_TYPE)
+ : validate_arglist (exp, INTEGER_TYPE, VOID_TYPE));
+
+ if (!valid_arglist)
return NULL_RTX;
/* Compute the argument. */
op0 = expand_normal (CALL_EXPR_ARG (exp, 0));
+ /* Compute the alignment. */
+ align = (alloca_with_align
+ ? TREE_INT_CST_LOW (CALL_EXPR_ARG (exp, 1))
+ : BIGGEST_ALIGNMENT);
+
/* Allocate the desired space. */
- result = allocate_dynamic_stack_space (op0, 0, BIGGEST_ALIGNMENT,
- cannot_accumulate);
+ result = allocate_dynamic_stack_space (op0, 0, align, cannot_accumulate);
result = convert_memory_address (ptr_mode, result);
return result;
@@ -5304,6 +5317,7 @@ expand_builtin (tree exp, rtx target, rtx subtarget, enum machine_mode mode,
&& !called_as_built_in (fndecl)
&& DECL_ASSEMBLER_NAME_SET_P (fndecl)
&& fcode != BUILT_IN_ALLOCA
+ && fcode != BUILT_IN_ALLOCA_WITH_ALIGN
&& fcode != BUILT_IN_FREE)
return expand_call (exp, target, ignore);
@@ -5559,6 +5573,7 @@ expand_builtin (tree exp, rtx target, rtx subtarget, enum machine_mode mode,
return XEXP (DECL_RTL (DECL_RESULT (current_function_decl)), 0);
case BUILT_IN_ALLOCA:
+ case BUILT_IN_ALLOCA_WITH_ALIGN:
/* If the allocation stems from the declaration of a variable-sized
object, it cannot accumulate. */
target = expand_builtin_alloca (exp, CALL_ALLOCA_FOR_VAR_P (exp));
@@ -13568,6 +13583,7 @@ is_inexpensive_builtin (tree decl)
{
case BUILT_IN_ABS:
case BUILT_IN_ALLOCA:
+ case BUILT_IN_ALLOCA_WITH_ALIGN:
case BUILT_IN_BSWAP32:
case BUILT_IN_BSWAP64:
case BUILT_IN_CLZ: