https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80158
--- Comment #12 from rguenther at suse dot de <rguenther at suse dot de> --- On Thu, 23 Mar 2017, wschmidt at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80158 > > --- Comment #10 from Bill Schmidt <wschmidt at gcc dot gnu.org> --- > Pretty certain the problem is in this chunk: > > if (bump == 0) > { > tree lhs = gimple_assign_lhs (c->cand_stmt); > gassign *copy_stmt = gimple_build_assign (lhs, basis_name); > gimple_stmt_iterator gsi = gsi_for_stmt (c->cand_stmt); > gimple_set_location (copy_stmt, gimple_location (c->cand_stmt)); > gsi_replace (&gsi, copy_stmt, false); > c->cand_stmt = copy_stmt; > if (dump_file && (dump_flags & TDF_DETAILS)) > stmt_to_print = copy_stmt; > } > > We need a gimple_set_bb (copy_stmt, gimple_bb (c->cand_stmt)) in here if we're > going to rely on the BB information for dominators subsequently. There may be > other cases like this in the code. But copy_stmt should have a BB as you did a gsi_replace on it. The stmt in question that causes the crash has none. Instead I susepct somehwere we replace the affected stmt but keep a dangling c->cand_stmt pointing to it around.