From 6e93d308ad01bb2bdf4a0ed1bce1bfd7037d7a15 Mon Sep 17 00:00:00 2001 From: rguenth Date: Fri, 2 Sep 2011 11:53:55 +0000 Subject: [PATCH] 2011-09-02 Richard Guenther * tree-ssa-ccp.c (fold_builtin_alloca_for_var): Do not fold alloca (0). (ccp_fold_stmt): Continue replacing args when folding alloca fails. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@178465 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 7 +++++++ gcc/tree-ssa-ccp.c | 18 +++++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ffd2855a31b..e8cdf9e71f4 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2011-09-02 Richard Guenther + + * tree-ssa-ccp.c (fold_builtin_alloca_for_var): Do not + fold alloca (0). + (ccp_fold_stmt): Continue replacing args when folding + alloca fails. + 2011-08-31 Richard Guenther * expr.c (expand_expr_real_2): Move COND_EXPR and VEC_COND_EXPR diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c index 007e17dd8b6..fc8d74780ea 100644 --- a/gcc/tree-ssa-ccp.c +++ b/gcc/tree-ssa-ccp.c @@ -1702,10 +1702,14 @@ fold_builtin_alloca_for_var (gimple stmt) /* Detect constant argument. */ arg = get_constant_value (gimple_call_arg (stmt, 0)); - if (arg == NULL_TREE || TREE_CODE (arg) != INTEGER_CST + if (arg == NULL_TREE + || TREE_CODE (arg) != INTEGER_CST || !host_integerp (arg, 1)) 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); @@ -1804,12 +1808,12 @@ ccp_fold_stmt (gimple_stmt_iterator *gsi) if (gimple_call_alloca_for_var_p (stmt)) { tree new_rhs = fold_builtin_alloca_for_var (stmt); - bool res; - if (new_rhs == NULL_TREE) - return false; - res = update_call_from_tree (gsi, new_rhs); - gcc_assert (res); - return true; + if (new_rhs) + { + bool res = update_call_from_tree (gsi, new_rhs); + gcc_assert (res); + return true; + } } /* Propagate into the call arguments. Compared to replace_uses_in -- 2.11.0