Martin's alloca work flagged this code as problematical. Essentially if we had a statement with no operands and the statement was not in the hash table, then we could end up performing alloca (0), which is inadvisable.
We can safely just avoid the whole block of code if there are no operands. Bootstrapped and regression tested on x86_64-linux-gnu.
Installed on the trunk. Jeff
commit 790bfbe1974f0b8d1cb23f73635221f4ccb4dafe Author: law <law@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Fri Dec 2 06:40:57 2016 +0000 * tree-ssa-threadedge.c (record_temporary_equivalences_from_stmts_at_dest): Avoid temporary propagation of operands if there are no operands. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@243152 138bc75d-0d04-0410-961f-82ee72b054a4 diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c3170c0..75881ee 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-12-01 Jeff Law <l...@redhat.com> + + * tree-ssa-threadedge.c + (record_temporary_equivalences_from_stmts_at_dest): Avoid temporary + propagation of operands if there are no operands. + 2016-12-02 Jakub Jelinek <ja...@redhat.com> PR tree-optimization/78586 diff --git a/gcc/tree-ssa-threadedge.c b/gcc/tree-ssa-threadedge.c index 534292c..3fdd59e 100644 --- a/gcc/tree-ssa-threadedge.c +++ b/gcc/tree-ssa-threadedge.c @@ -328,9 +328,10 @@ record_temporary_equivalences_from_stmts_at_dest (edge e, SSA_NAME_VALUE in addition to its own lattice. */ cached_lhs = gimple_fold_stmt_to_constant_1 (stmt, threadedge_valueize); - if (!cached_lhs - || (TREE_CODE (cached_lhs) != SSA_NAME - && !is_gimple_min_invariant (cached_lhs))) + if (NUM_SSA_OPERANDS (stmt, SSA_OP_ALL_USES) != 0 + && (!cached_lhs + || (TREE_CODE (cached_lhs) != SSA_NAME + && !is_gimple_min_invariant (cached_lhs)))) { /* We're going to temporarily copy propagate the operands and see if that allows us to simplify this statement. */