]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
cfgexpand.c (add_stack_var): Assert that the alignment is not zero.
authorEric Botcazou <ebotcazou@adacore.com>
Sat, 3 Sep 2011 14:56:53 +0000 (14:56 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Sat, 3 Sep 2011 14:56:53 +0000 (14:56 +0000)
* cfgexpand.c (add_stack_var): Assert that the alignment is not zero.
* tree-ssa-ccp.c (fold_builtin_alloca_for_var): Revert latest change.
Force at least BITS_PER_UNIT alignment on the new variable.

From-SVN: r178499

gcc/ChangeLog
gcc/cfgexpand.c
gcc/tree-ssa-ccp.c

index 48bdefac5c647fdb133c8fe28ac781b4be1e393d..8da81f7cbe3fa4435fcf14e6b55851f3b5e42cb1 100644 (file)
@@ -1,3 +1,9 @@
+2011-09-03  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * cfgexpand.c (add_stack_var): Assert that the alignment is not zero.
+       * tree-ssa-ccp.c (fold_builtin_alloca_for_var): Revert latest change.
+       Force at least BITS_PER_UNIT alignment on the new variable.
+
 2011-09-02  Gary Funck <gary@intrepid.com>
 
        * opts.c (print_specific_help): Fix off-by-one compare in
index 03a4409eeda902c6c39c901ce6ddf2bf1c46b767..1495633840bb11f73d497c8e28d36da9698f9826 100644 (file)
@@ -271,6 +271,8 @@ add_stack_var (tree decl)
   if (v->size == 0)
     v->size = 1;
   v->alignb = align_local_variable (SSAVAR (decl));
+  /* An alignment of zero can mightily confuse us later.  */
+  gcc_assert (v->alignb != 0);
 
   /* All variables are initially in their own partition.  */
   v->representative = stack_vars_num;
index fc8d74780eaad9fad7b97251c746af4deb953790..fc59d386cad5c65bbb55438d533f8f90ea87dfc7 100644 (file)
@@ -1708,8 +1708,6 @@ fold_builtin_alloca_for_var (gimple stmt)
     return NULL_TREE;
 
   size = TREE_INT_CST_LOW (arg);
-  if (size == 0)
-    return NULL_TREE;
 
   /* Heuristic: don't fold large vlas.  */
   threshold = (unsigned HOST_WIDE_INT)PARAM_VALUE (PARAM_LARGE_STACK_FRAME);
@@ -1726,6 +1724,8 @@ fold_builtin_alloca_for_var (gimple stmt)
   elem_type = build_nonstandard_integer_type (BITS_PER_UNIT, 1);
   n_elem = size * 8 / BITS_PER_UNIT;
   align = MIN (size * 8, BIGGEST_ALIGNMENT);
+  if (align < BITS_PER_UNIT)
+    align = BITS_PER_UNIT;
   array_type = build_array_type_nelts (elem_type, n_elem);
   var = create_tmp_var (array_type, NULL);
   DECL_ALIGN (var) = align;