mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 20:32:21 +00:00
Rewrite previous patch to follow Chris' stylistic
preference; no functional change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78391 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b7f40c1a2a
commit
1c5a28706d
@ -850,6 +850,27 @@ bool BranchFolder::CanFallThrough(MachineBasicBlock *CurBB) {
|
||||
return CanFallThrough(CurBB, CurUnAnalyzable, TBB, FBB, Cond);
|
||||
}
|
||||
|
||||
/// RemoveDuplicateSuccessor - make sure block Pred has at most one
|
||||
/// successor edge leading to Succ. This is only called in one place,
|
||||
/// but Chris prefers that it be a separate function.
|
||||
static void RemoveDuplicateSuccessor(MachineBasicBlock *Pred,
|
||||
MachineBasicBlock *Succ) {
|
||||
MachineBasicBlock::succ_iterator SI = Pred->succ_begin();
|
||||
bool found = false;
|
||||
while (SI != Pred->succ_end()) {
|
||||
if (*SI == Succ) {
|
||||
if (!found) {
|
||||
found = true;
|
||||
++SI;
|
||||
} else {
|
||||
SI = Pred->removeSuccessor(SI);
|
||||
}
|
||||
} else {
|
||||
++SI;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// IsBetterFallthrough - Return true if it would be clearly better to
|
||||
/// fall-through to MBB1 than to fall through into MBB2. This has to return
|
||||
/// a strict ordering, returning true for both (MBB1,MBB2) and (MBB2,MBB1) will
|
||||
@ -896,20 +917,7 @@ void BranchFolder::OptimizeBlock(MachineBasicBlock *MBB) {
|
||||
// If this resulted in a predecessor with true and false edges
|
||||
// both going to the fallthrough block, clean up;
|
||||
// BranchFolding doesn't like this.
|
||||
MachineBasicBlock::succ_iterator SI = Pred->succ_begin();
|
||||
bool found = false;
|
||||
while (SI != Pred->succ_end()) {
|
||||
if (*SI == FallThrough) {
|
||||
if (!found) {
|
||||
found = true;
|
||||
++SI;
|
||||
} else {
|
||||
SI = Pred->removeSuccessor(SI);
|
||||
}
|
||||
} else {
|
||||
++SI;
|
||||
}
|
||||
}
|
||||
RemoveDuplicateSuccessor(Pred, FallThrough);
|
||||
}
|
||||
// If MBB was the target of a jump table, update jump tables to go to the
|
||||
// fallthrough instead.
|
||||
|
Loading…
Reference in New Issue
Block a user