[llvm-commits] patch
Bruno Cardoso Lopes
bruno.cardoso at gmail.com
Fri Apr 1 11:23:47 PDT 2011
LGTM, one minor note:
On Fri, Apr 1, 2011 at 3:10 PM, Akira Hatanaka <ahatanak at gmail.com> wrote:
> This patch modifies MipsAsmPrinter::isBlockOnlyReachableByFallthrough so
> that it handles delay slots correctly.
>
>
> Index: lib/Target/Mips/MipsAsmPrinter.cpp
> ===================================================================
> --- lib/Target/Mips/MipsAsmPrinter.cpp (revision 128718)
> +++ lib/Target/Mips/MipsAsmPrinter.cpp (working copy)
> @@ -247,7 +247,33 @@
> if (isa<SwitchInst>(bb->getTerminator()))
> return false;
>
> - return AsmPrinter::isBlockOnlyReachableByFallthrough(MBB);
> + // If this is a landing pad, it isn't a fall through. If it has no
> preds,
> + // then nothing falls through to it.
> + if (MBB->isLandingPad() || MBB->pred_empty())
> + return false;
> +
> + // If there isn't exactly one predecessor, it can't be a fall through.
> + MachineBasicBlock::const_pred_iterator PI = MBB->pred_begin(), PI2 = PI;
> + ++PI2;
> +
> + if (PI2 != MBB->pred_end())
> + return false;
> +
> + // The predecessor has to be immediately before this block.
> + if (!Pred->isLayoutSuccessor(MBB))
> + return false;
> +
> + // If the block is completely empty, then it definitely does fall
> through.
> + if (Pred->empty())
> + return true;
> +
> + // Otherwise, check the last instruction.
> + // Check if the last terminator is an unconditional branch.
> + MachineBasicBlock::const_iterator I = Pred->end();
> + while (I != Pred->begin() && !(--I)->getDesc().isTerminator())
> + ;
Use:
while (I != Pred->begin() && !(--I)->getDesc().isTerminator());
Instead of:
while (I != Pred->begin() && !(--I)->getDesc().isTerminator())
;
--
Bruno Cardoso Lopes
http://www.brunocardoso.cc
More information about the llvm-commits
mailing list