This patch modifies MipsAsmPrinter::isBlockOnlyReachableByFallthrough so that it handles delay slots correctly.<br><br><br>Index: lib/Target/Mips/MipsAsmPrinter.cpp<br>===================================================================<br>
--- lib/Target/Mips/MipsAsmPrinter.cpp  (revision 128718)<br>+++ lib/Target/Mips/MipsAsmPrinter.cpp  (working copy)<br>@@ -247,7 +247,33 @@<br>     if (isa<SwitchInst>(bb->getTerminator()))<br>       return false;<br>
<br>-  return AsmPrinter::isBlockOnlyReachableByFallthrough(MBB);<br>+  // If this is a landing pad, it isn't a fall through.  If it has no preds,<br>+  // then nothing falls through to it.<br>+  if (MBB->isLandingPad() || MBB->pred_empty())<br>
+    return false;<br>+<br>+  // If there isn't exactly one predecessor, it can't be a fall through.<br>+  MachineBasicBlock::const_pred_iterator PI = MBB->pred_begin(), PI2 = PI;<br>+  ++PI2;<br>+ <br>+  if (PI2 != MBB->pred_end())<br>
+    return false;  <br>+<br>+  // The predecessor has to be immediately before this block.<br>+  if (!Pred->isLayoutSuccessor(MBB))<br>+    return false;<br>+   <br>+  // If the block is completely empty, then it definitely does fall through.<br>
+  if (Pred->empty())<br>+    return true;<br>+  <br>+  // Otherwise, check the last instruction.<br>+  // Check if the last terminator is an unconditional branch.<br>+  MachineBasicBlock::const_iterator I = Pred->end();<br>
+  while (I != Pred->begin() && !(--I)->getDesc().isTerminator())<br>+    ;<br>+<br>+  return !I->getDesc().isBarrier();<br> }<br><br> // Print out an operand for an inline asm expression.<br><br>