mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-21 23:17:16 +00:00
Don't add CFG edges for redundant conditional branches.
IR that hasn't been through SimplifyCFG can look like this: br i1 %b, label %r, label %r Make sure we don't create duplicate Machine CFG edges in this case. Fix the machine code verifier to accept conditional branches with a single CFG edge. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162230 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -580,7 +580,15 @@ MachineVerifier::visitMachineBasicBlockBefore(const MachineBasicBlock *MBB) {
|
||||
++MBBI;
|
||||
if (MBBI == MF->end()) {
|
||||
report("MBB conditionally falls through out of function!", MBB);
|
||||
} if (MBB->succ_size() != 2) {
|
||||
} if (MBB->succ_size() == 1) {
|
||||
// A conditional branch with only one successor is weird, but allowed.
|
||||
if (&*MBBI != TBB)
|
||||
report("MBB exits via conditional branch/fall-through but only has "
|
||||
"one CFG successor!", MBB);
|
||||
else if (TBB != *MBB->succ_begin())
|
||||
report("MBB exits via conditional branch/fall-through but the CFG "
|
||||
"successor don't match the actual successor!", MBB);
|
||||
} else if (MBB->succ_size() != 2) {
|
||||
report("MBB exits via conditional branch/fall-through but doesn't have "
|
||||
"exactly two CFG successors!", MBB);
|
||||
} else if (!matchPair(MBB->succ_begin(), TBB, MBBI)) {
|
||||
@@ -600,7 +608,15 @@ MachineVerifier::visitMachineBasicBlockBefore(const MachineBasicBlock *MBB) {
|
||||
} else if (TBB && FBB) {
|
||||
// Block conditionally branches somewhere, otherwise branches
|
||||
// somewhere else.
|
||||
if (MBB->succ_size() != 2) {
|
||||
if (MBB->succ_size() == 1) {
|
||||
// A conditional branch with only one successor is weird, but allowed.
|
||||
if (FBB != TBB)
|
||||
report("MBB exits via conditional branch/branch through but only has "
|
||||
"one CFG successor!", MBB);
|
||||
else if (TBB != *MBB->succ_begin())
|
||||
report("MBB exits via conditional branch/branch through but the CFG "
|
||||
"successor don't match the actual successor!", MBB);
|
||||
} else if (MBB->succ_size() != 2) {
|
||||
report("MBB exits via conditional branch/branch but doesn't have "
|
||||
"exactly two CFG successors!", MBB);
|
||||
} else if (!matchPair(MBB->succ_begin(), TBB, FBB)) {
|
||||
|
||||
Reference in New Issue
Block a user