re PR rtl-optimization/51051 (build fails on cris-elf building libstdc++-v3)
authorBernd Schmidt <bernds@codesourcery.com>
Mon, 14 Nov 2011 23:31:13 +0000 (23:31 +0000)
committerHans-Peter Nilsson <hp@gcc.gnu.org>
Mon, 14 Nov 2011 23:31:13 +0000 (23:31 +0000)
PR rtl-optimization/51051
* cfgrtl.c (cfg_layout_can_merge_blocks_p): Return FALSE if the
move would cause fallthrough into the exit block.

From-SVN: r181371

gcc/ChangeLog
gcc/cfgrtl.c

index 13de48b055291a04669915bd448c758a78677fd3..2e225e752c11e462d61f74f4707b6a7fc9b6e892 100644 (file)
@@ -1,3 +1,9 @@
+2011-11-15  Bernd Schmidt  <bernds@codesourcery.com>
+
+       PR rtl-optimization/51051
+       * cfgrtl.c (cfg_layout_can_merge_blocks_p): Return FALSE if the
+       move would cause fallthrough into the exit block.
+
 2011-11-14  Richard Henderson  <rth@redhat.com>
 
        * config/rs6000/rs6000.c (emit_load_locked): Assert the mode is handled.
index 16e2eb30a6a77f371108b1809d46db5985a8713d..aeb4ba184e16dc6881c0441bd022b84431bf8fc1 100644 (file)
@@ -2735,6 +2735,16 @@ cfg_layout_can_merge_blocks_p (basic_block a, basic_block b)
   if (BB_PARTITION (a) != BB_PARTITION (b))
     return false;
 
+  /* If we would end up moving B's instructions, make sure it doesn't fall
+     through into the exit block, since we cannot recover from a fallthrough
+     edge into the exit block occurring in the middle of a function.  */
+  if (NEXT_INSN (BB_END (a)) != BB_HEAD (b))
+    {
+      edge e = find_fallthru_edge (b->succs);
+      if (e && e->dest == EXIT_BLOCK_PTR)
+       return false;
+    }
+
   /* There must be exactly one edge in between the blocks.  */
   return (single_succ_p (a)
          && single_succ (a) == b