aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-ccp.c
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2011-09-02 11:53:55 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2011-09-02 11:53:55 +0000
commit5d882cc1dafe2546b34f1845f943b91f024dbac4 (patch)
tree35530c4c93e86c42422315de04acd16031bcc474 /gcc/tree-ssa-ccp.c
parent5da7fa30dae5648484fcd8e73add4bbeec0097ee (diff)
downloadgcc-5d882cc1dafe2546b34f1845f943b91f024dbac4.zip
gcc-5d882cc1dafe2546b34f1845f943b91f024dbac4.tar.gz
gcc-5d882cc1dafe2546b34f1845f943b91f024dbac4.tar.bz2
tree-ssa-ccp.c (fold_builtin_alloca_for_var): Do not fold alloca (0).
2011-09-02 Richard Guenther <rguenther@suse.de> * tree-ssa-ccp.c (fold_builtin_alloca_for_var): Do not fold alloca (0). (ccp_fold_stmt): Continue replacing args when folding alloca fails. From-SVN: r178465
Diffstat (limited to 'gcc/tree-ssa-ccp.c')
-rw-r--r--gcc/tree-ssa-ccp.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index 007e17d..fc8d747 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