summaryrefslogtreecommitdiff
path: root/lib/CodeGen/BranchFolding.cpp
diff options
context:
space:
mode:
authorDale Johannesen <dalej@apple.com>2007-05-31 21:54:00 +0000
committerDale Johannesen <dalej@apple.com>2007-05-31 21:54:00 +0000
commita52dd151378eeaad1369829b1dc3164874774e04 (patch)
tree8d3b01833a4cd8fbeddadf03ff4901e3b4921106 /lib/CodeGen/BranchFolding.cpp
parentf15d44cc108a1ce8139b3c80fff7b99cbd651333 (diff)
downloadllvm-a52dd151378eeaad1369829b1dc3164874774e04.tar.gz
llvm-a52dd151378eeaad1369829b1dc3164874774e04.tar.bz2
llvm-a52dd151378eeaad1369829b1dc3164874774e04.tar.xz
Arrange for only 1 of multiple branches to landing pad to be kept.
Do not remove empty landing pads (EH table needs to be updated) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37375 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/BranchFolding.cpp')
-rw-r--r--lib/CodeGen/BranchFolding.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/CodeGen/BranchFolding.cpp b/lib/CodeGen/BranchFolding.cpp
index 9d8bada4ba..48f74d94c8 100644
--- a/lib/CodeGen/BranchFolding.cpp
+++ b/lib/CodeGen/BranchFolding.cpp
@@ -684,18 +684,26 @@ static bool CorrectExtraCFGEdges(MachineBasicBlock &MBB,
}
}
- MachineBasicBlock::pred_iterator SI = MBB.succ_begin();
+ MachineBasicBlock::succ_iterator SI = MBB.succ_begin();
+ bool foundPad = false;
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()) {
+ } else if ((*SI)->isLandingPad() && !foundPad) {
+ foundPad = true;
++SI;
} else {
// Otherwise, this is a superfluous edge, remove it.
@@ -832,8 +840,9 @@ void BranchFolder::OptimizeBlock(MachineBasicBlock *MBB) {
++FallThrough;
// If this block is empty, make everyone use its fall-through, not the block
- // explicitly.
- if (MBB->empty()) {
+ // explicitly. Landing pads should not do this since the landing-pad table
+ // points to this block.
+ if (MBB->empty() && !MBB->isLandingPad()) {
// Dead block? Leave for cleanup later.
if (MBB->pred_empty()) return;