forked from OSchip/llvm-project
Fix CorrectExtraCFGEdges to allow for multiple LandingPad targets.
llvm-svn: 37394
This commit is contained in:
parent
9746e3a22b
commit
6e7cdce773
|
@ -675,6 +675,9 @@ bool BranchFolder::OptimizeBranches(MachineFunction &MF) {
|
||||||
/// CFG to be inserted. If we have proven that MBB can only branch to DestA and
|
/// CFG to be inserted. If we have proven that MBB can only branch to DestA and
|
||||||
/// DestB, remove any other MBB successors from the CFG. DestA and DestB can
|
/// DestB, remove any other MBB successors from the CFG. DestA and DestB can
|
||||||
/// be null.
|
/// be null.
|
||||||
|
/// Besides DestA and DestB, retain other edges leading to LandingPads (currently
|
||||||
|
/// there can be only one; we don't check or require that here).
|
||||||
|
/// Note it is possible that DestA and/or DestB are LandingPads.
|
||||||
static bool CorrectExtraCFGEdges(MachineBasicBlock &MBB,
|
static bool CorrectExtraCFGEdges(MachineBasicBlock &MBB,
|
||||||
MachineBasicBlock *DestA,
|
MachineBasicBlock *DestA,
|
||||||
MachineBasicBlock *DestB,
|
MachineBasicBlock *DestB,
|
||||||
|
@ -700,25 +703,19 @@ static bool CorrectExtraCFGEdges(MachineBasicBlock &MBB,
|
||||||
}
|
}
|
||||||
|
|
||||||
MachineBasicBlock::succ_iterator SI = MBB.succ_begin();
|
MachineBasicBlock::succ_iterator SI = MBB.succ_begin();
|
||||||
bool foundPad = false;
|
MachineBasicBlock *OrigDestA = DestA, *OrigDestB = DestB;
|
||||||
while (SI != MBB.succ_end()) {
|
while (SI != MBB.succ_end()) {
|
||||||
if (*SI == DestA && DestA == DestB) {
|
if (*SI == DestA && DestA == DestB) {
|
||||||
DestA = DestB = 0;
|
DestA = DestB = 0;
|
||||||
if ((*SI)->isLandingPad())
|
|
||||||
foundPad = true;
|
|
||||||
++SI;
|
++SI;
|
||||||
} else if (*SI == DestA) {
|
} else if (*SI == DestA) {
|
||||||
DestA = 0;
|
DestA = 0;
|
||||||
if ((*SI)->isLandingPad())
|
|
||||||
foundPad = true;
|
|
||||||
++SI;
|
++SI;
|
||||||
} else if (*SI == DestB) {
|
} else if (*SI == DestB) {
|
||||||
DestB = 0;
|
DestB = 0;
|
||||||
if ((*SI)->isLandingPad())
|
|
||||||
foundPad = true;
|
|
||||||
++SI;
|
++SI;
|
||||||
} else if ((*SI)->isLandingPad() && !foundPad) {
|
} else if ((*SI)->isLandingPad() &&
|
||||||
foundPad = true;
|
*SI!=OrigDestA && *SI!=OrigDestB) {
|
||||||
++SI;
|
++SI;
|
||||||
} else {
|
} else {
|
||||||
// Otherwise, this is a superfluous edge, remove it.
|
// Otherwise, this is a superfluous edge, remove it.
|
||||||
|
|
Loading…
Reference in New Issue