summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
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
commit70e294660ada0b78699f2e24ea82dec67a0d8d85 (patch)
tree04ce44ae28c613f155d9aedbf8e1da6a10a2a7fa /llvm/lib/Transforms
parent558a3ba17f324dbf12f090c58bdccbf859b02354 (diff)
downloadbcm5719-llvm-70e294660ada0b78699f2e24ea82dec67a0d8d85.tar.gz
bcm5719-llvm-70e294660ada0b78699f2e24ea82dec67a0d8d85.zip
Fix PR2029
llvm-svn: 47129
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Utils/LowerInvoke.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/LowerInvoke.cpp b/llvm/lib/Transforms/Utils/LowerInvoke.cpp
index 39738a09ba7..920a0286ead 100644
--- a/llvm/lib/Transforms/Utils/LowerInvoke.cpp
+++ b/llvm/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
OpenPOWER on IntegriCloud