Check null edge when deleting it in ccp_modify.
@@ -3220,6 +3220,8 @@ static int ccp_modify (gen_ctx_t gen_ctx) {
continue;
change_p = TRUE;
if (!res) {
+ edge_t e;
+
DEBUG (2, {
fprintf (debug_file, " removing branch insn ");
MIR_output_insn (ctx, debug_file, insn, curr_func_item->u.func, TRUE);
@@ -3227,7 +3229,8 @@ static int ccp_modify (gen_ctx_t gen_ctx) {
});
ccp_remove_insn_ssa_edges (gen_ctx, insn);
gen_delete_insn (gen_ctx, insn);
- delete_edge (DLIST_EL (out_edge_t, bb->out_edges, 1));
+ if ((e = DLIST_EL (out_edge_t, bb->out_edges, 1)) != NULL)
+ delete_edge (e); /* e can be arleady deleted by previous removing an unreachable BB */
deleted_branches_num++;
} else {
insn = MIR_new_insn (ctx, MIR_JMP, insn->ops[0]); /* label is always 0-th op */
