This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: ICE in gcc.dg/pr77834.c test for MIPS

Hi Segher,

Thank you for replying.

> From: Segher Boessenkool
> This happens when you have inserted code ending in a jump on an edge.
> This then will need updating of the CFG, and this code does not know
> how to do that.

Would the following be an appropriate solution ?

diff --git a/gcc/cfgrtl.c b/gcc/cfgrtl.c
index cafa38d..898d909 100644
--- a/gcc/cfgrtl.c
+++ b/gcc/cfgrtl.c
@@ -2047,6 +2047,16 @@ commit_one_edge_insertion (edge e)
         after = BB_END (bb);
+  /* If the edge contains control flow instructions, remember to update the
+     CFG after the insertion.  */
+  bool update_cfg = false;
+  for (tmp = insns; tmp && update_cfg == false; tmp = NEXT_INSN (tmp))
+     if (control_flow_insn_p (tmp))
+       {
+	 update_cfg = true;
+	 break;
+       }
   /* Now that we've found the spot, do the insertion.  */
   if (before)
@@ -2056,6 +2066,15 @@ commit_one_edge_insertion (edge e)
     last = emit_insn_after_noloc (insns, after, bb);
+  if (update_cfg)
+    {
+      auto_sbitmap blocks (last_basic_block_for_fn (cfun));
+      bitmap_ones (blocks);
+      find_many_sub_basic_blocks (blocks);
+      last = BB_END (bb);
+    }
   if (returnjump_p (last))
       /* ??? Remove all outgoing edges from BB and add one for EXIT.

In short, I'm updating the CFG by calling find_many_sub_basic_blocks with an
all-one block bitmap (this also happens in cfgexpand.c, after the edge
insertions) whenever an edge contains an insn which satisfies control_flow_insn_p.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]