From b9a4d2ba48c98fb0cc894489a26f1b16b01b1ecd Mon Sep 17 00:00:00 2001 From: Jeff Law Date: Mon, 8 Jan 2018 11:17:51 -0700 Subject: [PATCH] re PR rtl-optimization/81308 (ICE in calc_dfs_tree, at dominance.c:458) PR rtl-optimization/81308 * recog.c (split_all_insns): Conditionally cleanup the CFG after splitting insns. From-SVN: r256348 --- gcc/ChangeLog | 6 ++++++ gcc/recog.c | 28 +++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 27292bb449e..762aea53b17 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-01-08 Jeff Law + + PR rtl-optimization/81308 + * recog.c (split_all_insns): Conditionally cleanup the CFG after + splitting insns. + 2018-01-08 Vidya Praveen PR target/83663 - Revert r255946 diff --git a/gcc/recog.c b/gcc/recog.c index d6aa9036f57..cc28b71ba48 100644 --- a/gcc/recog.c +++ b/gcc/recog.c @@ -2931,6 +2931,7 @@ void split_all_insns (void) { bool changed; + bool need_cfg_cleanup = false; basic_block bb; auto_sbitmap blocks (last_basic_block_for_fn (cfun)); @@ -2949,6 +2950,18 @@ split_all_insns (void) CODE_LABELS and short-out basic blocks. */ next = NEXT_INSN (insn); finish = (insn == BB_END (bb)); + + /* If INSN has a REG_EH_REGION note and we split INSN, the + resulting split may not have/need REG_EH_REGION notes. + + If that happens and INSN was the last reference to the + given EH region, then the EH region will become unreachable. + We can not leave the unreachable blocks in the CFG as that + will trigger a checking failure. + + So track if INSN has a REG_EH_REGION note. If so and we + split INSN, then trigger a CFG cleanup. */ + rtx note = find_reg_note (insn, REG_EH_REGION, NULL_RTX); if (INSN_P (insn)) { rtx set = single_set (insn); @@ -2965,6 +2978,8 @@ split_all_insns (void) nops then anyways. */ if (reload_completed) delete_insn_and_edges (insn); + if (note) + need_cfg_cleanup = true; } else { @@ -2972,6 +2987,8 @@ split_all_insns (void) { bitmap_set_bit (blocks, bb->index); changed = true; + if (note) + need_cfg_cleanup = true; } } } @@ -2980,7 +2997,16 @@ split_all_insns (void) default_rtl_profile (); if (changed) - find_many_sub_basic_blocks (blocks); + { + find_many_sub_basic_blocks (blocks); + + /* Splitting could drop an REG_EH_REGION if it potentially + trapped in its original form, but does not in its split + form. Consider a FLOAT_TRUNCATE which splits into a memory + store/load pair and -fnon-call-exceptions. */ + if (need_cfg_cleanup) + cleanup_cfg (0); + } checking_verify_flow_info (); } -- 2.30.2