diff options
author | Jim Grosbach <grosbach@apple.com> | 2009-11-17 01:21:04 +0000 |
---|---|---|
committer | Jim Grosbach <grosbach@apple.com> | 2009-11-17 01:21:04 +0000 |
commit | a0a95a3c1cea79757854cf39ba07734b39e2b0e9 (patch) | |
tree | 4582e5068e246ba2d567427ebc40a7afae470c47 | |
parent | 2cbe71cdf0550b4d27b4d9e7d61a26d97ca6debe (diff) |
When moving a block for table jumps, make sure the prior block terminator
is analyzable so it can be updated. If it's not, be safe and don't move the
block.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89022 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Target/ARM/ARMConstantIslandPass.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/Target/ARM/ARMConstantIslandPass.cpp b/lib/Target/ARM/ARMConstantIslandPass.cpp index 0eb72272c0..734e33d2e6 100644 --- a/lib/Target/ARM/ARMConstantIslandPass.cpp +++ b/lib/Target/ARM/ARMConstantIslandPass.cpp @@ -1749,21 +1749,23 @@ AdjustJTTargetBlockForward(MachineBasicBlock *BB, MachineBasicBlock *JTBB) // heuristic. FIXME: We can definitely improve it. MachineBasicBlock *TBB = 0, *FBB = 0; SmallVector<MachineOperand, 4> Cond; + SmallVector<MachineOperand, 4> CondPrior; + MachineFunction::iterator BBi = BB; + MachineFunction::iterator OldPrior = prior(BBi); // If the block terminator isn't analyzable, don't try to move the block - if (TII->AnalyzeBranch(*BB, TBB, FBB, Cond)) - return NULL; + bool B = TII->AnalyzeBranch(*BB, TBB, FBB, Cond); - // If the block ends in an unconditional branch, move it. Be paranoid + // If the block ends in an unconditional branch, move it. The prior block + // has to have an analyzable terminator for us to move this one. Be paranoid // and make sure we're not trying to move the entry block of the function. - if (Cond.empty() && BB != MF.begin()) { - MachineFunction::iterator BBi = BB; - MachineFunction::iterator OldPrior = prior(BBi); + if (!B && Cond.empty() && BB != MF.begin() && + !TII->AnalyzeBranch(*OldPrior, TBB, FBB, CondPrior)) { BB->moveAfter(JTBB); OldPrior->updateTerminator(); BB->updateTerminator(); // Update numbering to account for the block being moved. - MF.RenumberBlocks(OldPrior); + MF.RenumberBlocks(); ++NumJTMoved; return NULL; } |