Fixing a bug with WinEH PHI handling

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232851 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Andrew Kaylor
2015-03-20 21:42:54 +00:00
parent 39110ecd35
commit e0e1c1d94d
3 changed files with 271 additions and 5 deletions

View File

@@ -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.