When pass outof_cfglayout is adding barriers, it appears that it misses some situations and then runs into "ICE: missing barrier" in the remainder (or, with checking disabled, into some other assertion).

cfgrtl.c:fixup_reorder_chain() reads:


  /* Now add jumps and labels as needed to match the blocks new
     outgoing edges.  */

  for (bb = ENTRY_BLOCK_PTR_FOR_FN (cfun)->next_bb; bb ; bb = (basic_block)
       bb->aux)
    {
      ...
      bb_end_insn = BB_END (bb);

      if (JUMP_P (bb_end_insn))
        {
          ret_label = JUMP_LABEL (bb_end_insn);
        
          if (any_condjump_p (bb_end_insn))
            { ... }
          else if (extract_asm_operands (PATTERN (bb_end_insn)) != NULL)
            { ... }
          else
            {
              /* Otherwise we have some return, switch or computed
                 jump.  In the 99% case, there should not have been a
                 fallthru edge.  */
              gcc_assert (returnjump_p (bb_end_insn) || !e_fall);
              continue;
            }


The last else is entered for an UNconditional jump with e_fall = 0 so that after the unconditional jump_insn no barrier is emit.

Now I am unsure about the right condition when to add the missing barrier; the following change works, but presumably the condition is only 99% correct ;-)


@@ -3822,6 +3842,11 @@ fixup_reorder_chain (void)
                 jump.  In the 99% case, there should not have been a
                 fallthru edge.  */
              gcc_assert (returnjump_p (bb_end_insn) || !e_fall);
+             if (!returnjump_p (bb_end_insn)
+                 && e_taken)
+               {
+                 emit_barrier_after (bb_end_insn);
+               }
              continue;
            }
        }

The respective BB has just that unconditional jump_insn; it is generated by CSE1 as it optimized a switch statement and was originally some conditional jump (-fno-jump-tables) or computed jump (with -fjump-tables):


(note 172 109 180 19 [bb 19] NOTE_INSN_BASIC_BLOCK)
(jump_insn 180 172 117 19 (set (pc)
        (label_ref 133)) bug.c:33 -1
     (nil)
 -> 133)

basic block 19, loop depth 0, count 0, freq 4623, maybe hot
Invalid sum of incoming frequencies 5156, should be 4623
 prev block 18, next block 20, flags: (REACHABLE, RTL, MODIFIED)
 pred:       18 [100.0%]  (FALLTHRU)
 succ:       23 [100.0%]


As I am not familiar with the assertions of outof_cfglayout, some help would be great. Is that the right place to fix the problem at all?


Johann

Reply via email to