[llvm-branch-commits] [llvm-branch] r91162 - in /llvm/branches/Apple/Zoidberg/lib/CodeGen: BranchFolding.cpp MachineBasicBlock.cpp
Bill Wendling
isanbard at gmail.com
Fri Dec 11 13:49:37 PST 2009
Author: void
Date: Fri Dec 11 15:49:37 2009
New Revision: 91162
URL: http://llvm.org/viewvc/llvm-project?rev=91162&view=rev
Log:
$ svn merge -c 91161 https://llvm.org/svn/llvm-project/llvm/trunk
--- Merging r91161 into '.':
U lib/CodeGen/BranchFolding.cpp
U lib/CodeGen/MachineBasicBlock.cpp
Modified:
llvm/branches/Apple/Zoidberg/lib/CodeGen/BranchFolding.cpp
llvm/branches/Apple/Zoidberg/lib/CodeGen/MachineBasicBlock.cpp
Modified: llvm/branches/Apple/Zoidberg/lib/CodeGen/BranchFolding.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/lib/CodeGen/BranchFolding.cpp?rev=91162&r1=91161&r2=91162&view=diff
==============================================================================
--- llvm/branches/Apple/Zoidberg/lib/CodeGen/BranchFolding.cpp (original)
+++ llvm/branches/Apple/Zoidberg/lib/CodeGen/BranchFolding.cpp Fri Dec 11 15:49:37 2009
@@ -1205,11 +1205,11 @@
}
}
- // If the prior block doesn't fall through into this block, and if this
- // block doesn't fall through into some other block, see if we can find a
- // place to move this block where a fall-through will happen.
- if (!PrevBB.canFallThrough()) {
-
+ // If the prior block doesn't fall through into this block and if this block
+ // doesn't fall through into some other block and it's not branching only to a
+ // landing pad, then see if we can find a place to move this block where a
+ // fall-through will happen.
+ if (!PrevBB.canFallThrough() && !MBB->BranchesToLandingPad(MBB)) {
// Now we know that there was no fall-through into this block, check to
// see if it has a fall-through into its successor.
bool CurFallsThru = MBB->canFallThrough();
@@ -1221,28 +1221,31 @@
E = MBB->pred_end(); PI != E; ++PI) {
// Analyze the branch at the end of the pred.
MachineBasicBlock *PredBB = *PI;
- MachineFunction::iterator PredFallthrough = PredBB; ++PredFallthrough;
+ MachineFunction::iterator PredNextBB = PredBB; ++PredNextBB;
MachineBasicBlock *PredTBB, *PredFBB;
SmallVector<MachineOperand, 4> PredCond;
- if (PredBB != MBB && !PredBB->canFallThrough() &&
- !TII->AnalyzeBranch(*PredBB, PredTBB, PredFBB, PredCond, true)
+ if (PredBB != MBB && !PredBB->canFallThrough()
+ && !TII->AnalyzeBranch(*PredBB, PredTBB, PredFBB, PredCond, true)
&& (!CurFallsThru || !CurTBB || !CurFBB)
&& (!CurFallsThru || MBB->getNumber() >= PredBB->getNumber())) {
- // If the current block doesn't fall through, just move it.
- // If the current block can fall through and does not end with a
- // conditional branch, we need to append an unconditional jump to
- // the (current) next block. To avoid a possible compile-time
- // infinite loop, move blocks only backward in this case.
- // Also, if there are already 2 branches here, we cannot add a third;
- // this means we have the case
- // Bcc next
- // B elsewhere
- // next:
+ // If the current block doesn't fall through, just move it. If the
+ // current block can fall through and does not end with a conditional
+ // branch, we need to append an unconditional jump to the (current)
+ // next block. To avoid a possible compile-time infinite loop, move
+ // blocks only backward in this case.
+ //
+ // Also, if there are already 2 branches here, we cannot add a third.
+ // I.e. we have the case:
+ //
+ // Bcc next
+ // B elsewhere
+ // next:
if (CurFallsThru) {
- MachineBasicBlock *NextBB = next(MachineFunction::iterator(MBB));
+ MachineBasicBlock *NextBB = MachineFunction::iterator(MBB);
CurCond.clear();
TII->InsertBranch(*MBB, NextBB, 0, CurCond);
}
+
MBB->moveAfter(PredBB);
MadeChange = true;
goto ReoptimizeBlock;
Modified: llvm/branches/Apple/Zoidberg/lib/CodeGen/MachineBasicBlock.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/lib/CodeGen/MachineBasicBlock.cpp?rev=91162&r1=91161&r2=91162&view=diff
==============================================================================
--- llvm/branches/Apple/Zoidberg/lib/CodeGen/MachineBasicBlock.cpp (original)
+++ llvm/branches/Apple/Zoidberg/lib/CodeGen/MachineBasicBlock.cpp Fri Dec 11 15:49:37 2009
@@ -457,16 +457,9 @@
SmallSet<const MachineBasicBlock*, 32> Visited;
const MachineBasicBlock *CurMBB = MBB;
- while (!Visited.count(CurMBB) && !CurMBB->isLandingPad()) {
- if (CurMBB->size() != 1 || CurMBB->succ_empty() || CurMBB->succ_size() != 1)
- break;
-
- const TargetInstrInfo *TII =
- CurMBB->getParent()->getTarget().getInstrInfo();
- if (!TII->isUnpredicatedTerminator(CurMBB->begin()))
- break;
-
- Visited.insert(CurMBB);
+ while (!CurMBB->isLandingPad()) {
+ if (CurMBB->succ_size() != 1) break;
+ if (!Visited.insert(CurMBB)) break;
CurMBB = *CurMBB->succ_begin();
}
More information about the llvm-branch-commits
mailing list