From eacac712e337690ee21ce37fd06b2fe8b10a58f1 Mon Sep 17 00:00:00 2001 From: Aldy Hernandez Date: Thu, 8 Feb 2018 11:16:25 +0000 Subject: [PATCH] re PR tree-optimization/84224 (ICE in execute, at gimple-ssa-warn-alloca.c:448) PR tree-optimization/84224 * gimple-ssa-warn-alloca.c (pass_walloca::execute): Remove assert. * calls.c (gimple_alloca_call_p): Only return TRUE when we have non-zero arguments. From-SVN: r257480 --- gcc/ChangeLog | 7 +++++++ gcc/calls.c | 2 +- gcc/gimple-ssa-warn-alloca.c | 1 - gcc/testsuite/gcc.dg/Walloca-16.c | 6 ++++++ 4 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/Walloca-16.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e51ba4f9310..84bf970575b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2018-02-08 Aldy Hernandez + + PR tree-optimization/84224 + * gimple-ssa-warn-alloca.c (pass_walloca::execute): Remove assert. + * calls.c (gimple_alloca_call_p): Only return TRUE when we have + non-zero arguments. + 2018-02-07 Iain Sandoe * config/rs6000/altivec.md (*restore_world): Remove LR use. diff --git a/gcc/calls.c b/gcc/calls.c index 54fea158631..19c95b8455b 100644 --- a/gcc/calls.c +++ b/gcc/calls.c @@ -730,7 +730,7 @@ gimple_alloca_call_p (const gimple *stmt) switch (DECL_FUNCTION_CODE (fndecl)) { CASE_BUILT_IN_ALLOCA: - return true; + return gimple_call_num_args (stmt) > 0; default: break; } diff --git a/gcc/gimple-ssa-warn-alloca.c b/gcc/gimple-ssa-warn-alloca.c index 941810a997e..327c806ae11 100644 --- a/gcc/gimple-ssa-warn-alloca.c +++ b/gcc/gimple-ssa-warn-alloca.c @@ -445,7 +445,6 @@ pass_walloca::execute (function *fun) if (!gimple_alloca_call_p (stmt)) continue; - gcc_assert (gimple_call_num_args (stmt) >= 1); const bool is_vla = gimple_call_alloca_for_var_p (as_a (stmt)); diff --git a/gcc/testsuite/gcc.dg/Walloca-16.c b/gcc/testsuite/gcc.dg/Walloca-16.c new file mode 100644 index 00000000000..3ee96a9570a --- /dev/null +++ b/gcc/testsuite/gcc.dg/Walloca-16.c @@ -0,0 +1,6 @@ +/* PR tree-optimization/84224 */ +/* { dg-do compile } */ +/* { dg-options "-O0 -Walloca" } */ + +void *alloca (); +__typeof__(alloca ()) a () { return alloca (); } -- 2.30.2