http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50678
--- Comment #8 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-10-11 11:02:08 UTC --- (In reply to comment #6) > > 2011-10-07 Tom de Vries <t...@codesourcery.com> > > > > PR middle-end/50527 > > * tree.c (build_common_builtin_nodes): Add local_define_builtin for > > * builtins.c (expand_builtin_alloca): Handle BUILT_IN_ALLOCA_WITH_ALIGN > > * tree-ssa-ccp.c (evaluate_stmt): Set align for > > * builtins.def (BUILT_IN_ALLOCA_WITH_ALIGN): Declare using > > * ipa-pure-const.c (special_builtin_state): Handle > > * tree-ssa-alias.c (ref_maybe_used_by_call_p_1) > > * function.c (gimplify_parameters): Lower vla to > > * 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) > > * varasm.c (incorporeal_function_p): Same. > > * tree-object-size.c (alloc_object_size): Same. > > * gimple.c (gimple_build_call_from_tree): Same. > > OK, I didn't realize that things were still ongoing on this front. Frankly, > this alloca folding seems to introduce far too much complication for what it's > worth. I think more properly tracking alignment requirements on VLAs makes sense to avoid excessive stack (re-)alignment. So the above patch would be independent on whether we fold the allocas to automatic vars or not. > Tom, did you consider reverting the whole thing and doing things differently? > > If your canonical example is something like: > > const int n = 5; > int array[n]; > > it's very easy to fold this in the front-end into: > > const int n = 5; > int array[5]; > > As a matter of fact, that's what we do in Ada, which is by far the biggest > user > of alloca in the compiler. And now Fortran with -fstack-arrays. Though those are very likely never folded to automatic vars. It would be nice to know whether this particular FAIL is the failure of some checking mechanism or a genuine wrong-code bug. I suppose it's the former, and for -fstack-check we could simply disable alloca folding.