aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms/Utils
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-02-14 19:18:13 +0000
committerChris Lattner <sabre@nondot.org>2008-02-14 19:18:13 +0000
commit3ff699e93c8ae7b636ddb4493a88206a72371506 (patch)
treeba5107e2c2686f6207dbfa42ec3faa375a74571d /lib/Transforms/Utils
parent69946fdd7428f0a1ccc7defc7c06533817bbf80e (diff)
downloadexternal_llvm-3ff699e93c8ae7b636ddb4493a88206a72371506.zip
external_llvm-3ff699e93c8ae7b636ddb4493a88206a72371506.tar.gz
external_llvm-3ff699e93c8ae7b636ddb4493a88206a72371506.tar.bz2
Fix PR2029
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47129 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils')
-rw-r--r--lib/Transforms/Utils/LowerInvoke.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/Transforms/Utils/LowerInvoke.cpp b/lib/Transforms/Utils/LowerInvoke.cpp
index 39738a0..920a028 100644
--- a/lib/Transforms/Utils/LowerInvoke.cpp
+++ b/lib/Transforms/Utils/LowerInvoke.cpp
@@ -256,6 +256,17 @@ void LowerInvoke::rewriteExpensiveInvoke(InvokeInst *II, unsigned InvokeNo,
SwitchInst *CatchSwitch) {
ConstantInt *InvokeNoC = ConstantInt::get(Type::Int32Ty, InvokeNo);
+ // If the unwind edge has phi nodes, split the edge.
+ if (isa<PHINode>(II->getUnwindDest()->begin())) {
+ SplitCriticalEdge(II, 1, this);
+
+ // If there are any phi nodes left, they must have a single predecessor.
+ while (PHINode *PN = dyn_cast<PHINode>(II->getUnwindDest()->begin())) {
+ PN->replaceAllUsesWith(PN->getIncomingValue(0));
+ PN->eraseFromParent();
+ }
+ }
+
// Insert a store of the invoke num before the invoke and store zero into the
// location afterward.
new StoreInst(InvokeNoC, InvokeNum, true, II); // volatile