summaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils/SimplifyCFG.cpp
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2008-03-09 05:10:13 +0000
committerNick Lewycky <nicholas@mxc.ca>2008-03-09 05:10:13 +0000
commit6af31aab63583e61b7c7b51bc285541750bd834f (patch)
tree3b96561ea1c35be2b27f9f2b8ce0bd1436c96270 /lib/Transforms/Utils/SimplifyCFG.cpp
parentc6694228fa8df57193cbd924d627814384106ba2 (diff)
downloadllvm-6af31aab63583e61b7c7b51bc285541750bd834f.tar.gz
llvm-6af31aab63583e61b7c7b51bc285541750bd834f.tar.bz2
llvm-6af31aab63583e61b7c7b51bc285541750bd834f.tar.xz
Update the inliner and simplifycfg to handle unwind_to.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48086 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r--lib/Transforms/Utils/SimplifyCFG.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp
index 2092c8b58a..61da0d998f 100644
--- a/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -1237,6 +1237,8 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
SmallVector<BasicBlock*, 8> UncondBranchPreds;
SmallVector<BranchInst*, 8> CondBranchPreds;
for (pred_iterator PI = pred_begin(BB), E = pred_end(BB); PI != E; ++PI) {
+ if ((*PI)->getUnwindDest() == BB) continue;
+
TerminatorInst *PTI = (*PI)->getTerminator();
if (BranchInst *BI = dyn_cast<BranchInst>(PTI)) {
if (BI->isUnconditional())
@@ -1788,6 +1790,7 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
BasicBlock *OnlySucc = 0;
if (OnlyPred && OnlyPred != BB && // Don't break self loops
+ OnlyPred->getUnwindDest() != BB &&
OnlyPred->getTerminator()->getOpcode() != Instruction::Invoke) {
// Check to see if there is only one distinct successor...
succ_iterator SI(succ_begin(OnlyPred)), SE(succ_end(OnlyPred));
@@ -1799,7 +1802,8 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
}
}
- if (OnlySucc) {
+ if (OnlySucc && (BB->getUnwindDest() == OnlyPred->getUnwindDest() ||
+ !BB->getUnwindDest() || !OnlyPred->getUnwindDest())) {
DOUT << "Merging: " << *BB << "into: " << *OnlyPred;
// Resolve any PHI nodes at the start of the block. They are all
@@ -1819,6 +1823,10 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
// Move all definitions in the successor to the predecessor.
OnlyPred->getInstList().splice(OnlyPred->end(), BB->getInstList());
+ // Move the unwind_to block
+ if (!OnlyPred->getUnwindDest() && BB->getUnwindDest())
+ OnlyPred->setUnwindDest(BB->getUnwindDest());
+
// Make all PHI nodes that referred to BB now refer to Pred as their
// source.
BB->replaceAllUsesWith(OnlyPred);