mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-29 10:25:12 +00:00
Revert r100056. It was causing a failure on MSVC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100062 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -23,7 +23,6 @@
|
|||||||
#include "llvm/Target/TargetMachine.h"
|
#include "llvm/Target/TargetMachine.h"
|
||||||
#include "llvm/Assembly/Writer.h"
|
#include "llvm/Assembly/Writer.h"
|
||||||
#include "llvm/ADT/SmallString.h"
|
#include "llvm/ADT/SmallString.h"
|
||||||
#include "llvm/ADT/SmallPtrSet.h"
|
|
||||||
#include "llvm/Support/Debug.h"
|
#include "llvm/Support/Debug.h"
|
||||||
#include "llvm/Support/LeakDetector.h"
|
#include "llvm/Support/LeakDetector.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
@@ -460,41 +459,54 @@ bool MachineBasicBlock::CorrectExtraCFGEdges(MachineBasicBlock *DestA,
|
|||||||
// conditional branch followed by an unconditional branch. DestA is the
|
// conditional branch followed by an unconditional branch. DestA is the
|
||||||
// 'true' destination and DestB is the 'false' destination.
|
// 'true' destination and DestB is the 'false' destination.
|
||||||
|
|
||||||
bool Changed = false;
|
bool MadeChange = false;
|
||||||
|
bool AddedFallThrough = false;
|
||||||
|
|
||||||
MachineFunction::iterator FallThru =
|
MachineFunction::iterator FallThru =
|
||||||
llvm::next(MachineFunction::iterator(this));
|
llvm::next(MachineFunction::iterator(this));
|
||||||
|
|
||||||
if (DestA == 0 && DestB == 0) {
|
if (isCond) {
|
||||||
// Block falls through to successor.
|
// If this block ends with a conditional branch that falls through to its
|
||||||
DestA = FallThru;
|
// successor, set DestB as the successor.
|
||||||
DestB = FallThru;
|
if (DestB == 0 && FallThru != getParent()->end()) {
|
||||||
} else if (DestA != 0 && DestB == 0) {
|
|
||||||
if (isCond)
|
|
||||||
// Block ends in conditional jump that falls through to successor.
|
|
||||||
DestB = FallThru;
|
DestB = FallThru;
|
||||||
|
AddedFallThrough = true;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
assert(DestA && DestB && isCond &&
|
// If this is an unconditional branch with no explicit dest, it must just be
|
||||||
"CFG in a bad state. Cannot correct CFG edges");
|
// a fallthrough into DestA.
|
||||||
|
if (DestA == 0 && FallThru != getParent()->end()) {
|
||||||
|
DestA = FallThru;
|
||||||
|
AddedFallThrough = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove superfluous edges. I.e., those which aren't destinations of this
|
|
||||||
// basic block, duplicate edges, or landing pads.
|
|
||||||
SmallPtrSet<const MachineBasicBlock*, 8> SeenMBBs;
|
|
||||||
MachineBasicBlock::succ_iterator SI = succ_begin();
|
MachineBasicBlock::succ_iterator SI = succ_begin();
|
||||||
|
MachineBasicBlock *OrigDestA = DestA, *OrigDestB = DestB;
|
||||||
while (SI != succ_end()) {
|
while (SI != succ_end()) {
|
||||||
const MachineBasicBlock *MBB = *SI;
|
const MachineBasicBlock *MBB = *SI;
|
||||||
if (!SeenMBBs.insert(MBB) ||
|
if (MBB == DestA) {
|
||||||
(MBB != DestA && MBB != DestB && !MBB->isLandingPad())) {
|
DestA = 0;
|
||||||
// This is a superfluous edge, remove it.
|
|
||||||
SI = removeSuccessor(SI);
|
|
||||||
Changed = true;
|
|
||||||
} else {
|
|
||||||
++SI;
|
++SI;
|
||||||
|
} else if (MBB == DestB) {
|
||||||
|
DestB = 0;
|
||||||
|
++SI;
|
||||||
|
} else if (MBB->isLandingPad() &&
|
||||||
|
MBB != OrigDestA && MBB != OrigDestB) {
|
||||||
|
++SI;
|
||||||
|
} else {
|
||||||
|
// Otherwise, this is a superfluous edge, remove it.
|
||||||
|
SI = removeSuccessor(SI);
|
||||||
|
MadeChange = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Changed;
|
if (!AddedFallThrough)
|
||||||
|
assert(DestA == 0 && DestB == 0 && "MachineCFG is missing edges!");
|
||||||
|
else if (isCond)
|
||||||
|
assert(DestA == 0 && "MachineCFG is missing edges!");
|
||||||
|
|
||||||
|
return MadeChange;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// findDebugLoc - find the next valid DebugLoc starting at MBBI, skipping
|
/// findDebugLoc - find the next valid DebugLoc starting at MBBI, skipping
|
||||||
|
Reference in New Issue
Block a user