summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorAndrew Kaylor <andrew.kaylor@intel.com>2015-03-20 21:42:54 +0000
committerAndrew Kaylor <andrew.kaylor@intel.com>2015-03-20 21:42:54 +0000
commit3170e5620e463b20688bc629bde08c5ca554ea11 (patch)
tree87630712f2ffc01a189729c53b611c9a5c671025 /llvm/lib/Transforms
parentc88f724fedeff64bd333668bdcda9d8d0a50f537 (diff)
downloadbcm5719-llvm-3170e5620e463b20688bc629bde08c5ca554ea11.tar.gz
bcm5719-llvm-3170e5620e463b20688bc629bde08c5ca554ea11.zip
Fixing a bug with WinEH PHI handling
llvm-svn: 232851
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Utils/CloneFunction.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Utils/CloneFunction.cpp b/llvm/lib/Transforms/Utils/CloneFunction.cpp
index 70532836513..f04ea9c29f5 100644
--- a/llvm/lib/Transforms/Utils/CloneFunction.cpp
+++ b/llvm/lib/Transforms/Utils/CloneFunction.cpp
@@ -524,11 +524,18 @@ void llvm::CloneAndPruneIntoFromInst(Function *NewFunc, const Function *OldFunc,
// Handle PHI nodes specially, as we have to remove references to dead
// blocks.
- for (BasicBlock::const_iterator I = BI->begin(), E = BI->end(); I != E; ++I)
- if (const PHINode *PN = dyn_cast<PHINode>(I))
- PHIToResolve.push_back(PN);
- else
+ for (BasicBlock::const_iterator I = BI->begin(), E = BI->end(); I != E; ++I) {
+ // PHI nodes may have been remapped to non-PHI nodes by the caller or
+ // during the cloning process.
+ if (const PHINode *PN = dyn_cast<PHINode>(I)) {
+ if (isa<PHINode>(VMap[PN]))
+ PHIToResolve.push_back(PN);
+ else
+ break;
+ } else {
break;
+ }
+ }
// Finally, remap the terminator instructions, as those can't be remapped
// until all BBs are mapped.
OpenPOWER on IntegriCloud