This is the mail archive of the gcc-patches@gcc.gnu.org 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]

CFG problem in PR 10056


This is a crash due to a problem with the CFG during block reordering.

What happens is that we have:

  (jump_insn:TI 1165 1161 1465 37 0x40590c8c (parallel [
	      (set (pc)
		  (if_then_else (eq (reg/v/f:SI 3 %r3 [255])
			  (const_int 0 [0x0]))
		      (label_ref 1197)
		      (pc)))
	      (set (reg/v/f:SI 3 %r3 [97])
		  (reg/v/f:SI 3 %r3 [255]))
	  ]) 232 {*pa.md:7462} (nil)
      (expr_list:REG_BR_PROB (const_int 5608 [0x15e8])
	  (nil)))
  ;; End of basic block 37, registers live:
   3 [%r3] 5 [%r5] 7 [%r7] 8 [%r8] 30 [%r30]

  ;; Start of basic block 38, registers live: 3 [%r3] 5 [%r5] 7 [%r7] 8 [%r8] 30 [%r30]
  (note 1465 1165 1627 38 [bb 38] NOTE_INSN_BASIC_BLOCK)

  (jump_insn:TI 1627 1465 1628 38 (nil) (set (pc)
	  (label_ref 1197)) 202 {jump} (nil)
      (nil))

So, block 37 has two outgoing edges: an EDGE_FALLTRHU into block 38,
and another edge to whatever block insn 1997 is in.

Then cleanup_unconditional_jumps says that since block 38 is a
forwarder-block, the edge out of block 37 to block 38 might as well
get redirected to 1997.  And redirect_edge_succ_nodup says that it
already has one of those, so we just trash the new edge.

But now fixup_reorder_chain gets confused:

      /* Find the old fallthru edge, and another non-EH edge for
	 a taken jump.  */
      e_taken = e_fall = NULL;
      for (e = bb->succ; e ; e = e->succ_next)
	if (e->flags & EDGE_FALLTHRU)
	  e_fall = e;
	else if (! (e->flags & EDGE_EH))
	  e_taken = e;

This wants to find a taken edge and a fallthru edge and there is only
one edge.  We crash a little bit later because e_taken is NULL.

Should we be preserving both edges, or does the logic in
fixup_reorder_chain need to deal with having only one edge for a
conditional jump?

--
Mark Mitchell
CodeSourcery, LLC
mark at codesourcery dot com


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