summaryrefslogtreecommitdiff
path: root/lib/CodeGen/SjLjEHPrepare.cpp
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2011-10-21 22:08:56 +0000
committerBill Wendling <isanbard@gmail.com>2011-10-21 22:08:56 +0000
commit0ad56122e585d3d27ea852115390a9e53cabc9d5 (patch)
tree264690670d218c8667456313c48fb5d5d731496b /lib/CodeGen/SjLjEHPrepare.cpp
parent675c02b0b9967f286b4d5aa8c3f7d8fc9e7988c4 (diff)
downloadllvm-0ad56122e585d3d27ea852115390a9e53cabc9d5.tar.gz
llvm-0ad56122e585d3d27ea852115390a9e53cabc9d5.tar.bz2
llvm-0ad56122e585d3d27ea852115390a9e53cabc9d5.tar.xz
Make sure that the landing pads themselves have no PHI instructions in them.
The assumption in the back-end is that PHIs are not allowed at the start of the landing pad block for SjLj exceptions. <rdar://problem/10313708> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142689 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SjLjEHPrepare.cpp')
-rw-r--r--lib/CodeGen/SjLjEHPrepare.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/CodeGen/SjLjEHPrepare.cpp b/lib/CodeGen/SjLjEHPrepare.cpp
index 3ccf39ba24..e5cb1bb6ea 100644
--- a/lib/CodeGen/SjLjEHPrepare.cpp
+++ b/lib/CodeGen/SjLjEHPrepare.cpp
@@ -908,6 +908,27 @@ void SjLjEHPass::lowerAcrossUnwindEdges(Function &F,
}
}
}
+
+ // Go through the landing pads and remove any PHIs there.
+ for (unsigned i = 0, e = Invokes.size(); i != e; ++i) {
+ BasicBlock *UnwindBlock = Invokes[i]->getUnwindDest();
+ LandingPadInst *LPI = UnwindBlock->getLandingPadInst();
+
+ // Place PHIs into a set to avoid invalidating the iterator.
+ SmallPtrSet<PHINode*, 8> PHIsToDemote;
+ for (BasicBlock::iterator
+ PN = UnwindBlock->begin(); isa<PHINode>(PN); ++PN)
+ PHIsToDemote.insert(cast<PHINode>(PN));
+ if (PHIsToDemote.empty()) continue;
+
+ // Demote the PHIs to the stack.
+ for (SmallPtrSet<PHINode*, 8>::iterator
+ I = PHIsToDemote.begin(), E = PHIsToDemote.end(); I != E; ++I)
+ DemotePHIToStack(*I);
+
+ // Move the landingpad instruction back to the top of the landing pad block.
+ LPI->moveBefore(UnwindBlock->begin());
+ }
}
/// setupEntryBlockAndCallSites - Setup the entry block by creating and filling