summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/BranchFolding.cpp
diff options
context:
space:
mode:
authorDale Johannesen <dalej@apple.com>2007-06-02 00:08:15 +0000
committerDale Johannesen <dalej@apple.com>2007-06-02 00:08:15 +0000
commit6e7cdce773f04bf71c65ce61011ba62025c00928 (patch)
tree750fa0a276ad12da5065c349ec79da59a9bd9f22 /llvm/lib/CodeGen/BranchFolding.cpp
parent9746e3a22bb29a8e72632772186c7cb9871d0974 (diff)
downloadbcm5719-llvm-6e7cdce773f04bf71c65ce61011ba62025c00928.tar.gz
bcm5719-llvm-6e7cdce773f04bf71c65ce61011ba62025c00928.zip
Fix CorrectExtraCFGEdges to allow for multiple LandingPad targets.
llvm-svn: 37394
Diffstat (limited to 'llvm/lib/CodeGen/BranchFolding.cpp')
-rw-r--r--llvm/lib/CodeGen/BranchFolding.cpp15
1 files changed, 6 insertions, 9 deletions
diff --git a/llvm/lib/CodeGen/BranchFolding.cpp b/llvm/lib/CodeGen/BranchFolding.cpp
index 8093b29791e..53cf0aabb9f 100644
--- a/llvm/lib/CodeGen/BranchFolding.cpp
+++ b/llvm/lib/CodeGen/BranchFolding.cpp
@@ -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
/// DestB, remove any other MBB successors from the CFG. DestA and DestB can
/// 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,
MachineBasicBlock *DestA,
MachineBasicBlock *DestB,
@@ -700,25 +703,19 @@ static bool CorrectExtraCFGEdges(MachineBasicBlock &MBB,
}
MachineBasicBlock::succ_iterator SI = MBB.succ_begin();
- bool foundPad = false;
+ MachineBasicBlock *OrigDestA = DestA, *OrigDestB = DestB;
while (SI != MBB.succ_end()) {
if (*SI == DestA && DestA == DestB) {
DestA = DestB = 0;
- if ((*SI)->isLandingPad())
- foundPad = true;
++SI;
} else if (*SI == DestA) {
DestA = 0;
- if ((*SI)->isLandingPad())
- foundPad = true;
++SI;
} else if (*SI == DestB) {
DestB = 0;
- if ((*SI)->isLandingPad())
- foundPad = true;
++SI;
- } else if ((*SI)->isLandingPad() && !foundPad) {
- foundPad = true;
+ } else if ((*SI)->isLandingPad() &&
+ *SI!=OrigDestA && *SI!=OrigDestB) {
++SI;
} else {
// Otherwise, this is a superfluous edge, remove it.
OpenPOWER on IntegriCloud