When extracting SEME regions of code, the extractor needs to update the dominator tree for split return blocks.

llvm-svn: 79957
This commit is contained in:
Owen Anderson 2009-08-24 23:32:14 +00:00
parent 3444be8f21
commit 7113af190c

View File

@ -183,8 +183,24 @@ void CodeExtractor::severSplitPHINodes(BasicBlock *&Header) {
void CodeExtractor::splitReturnBlocks() {
for (std::set<BasicBlock*>::iterator I = BlocksToExtract.begin(),
E = BlocksToExtract.end(); I != E; ++I)
if (ReturnInst *RI = dyn_cast<ReturnInst>((*I)->getTerminator()))
(*I)->splitBasicBlock(RI, (*I)->getName()+".ret");
if (ReturnInst *RI = dyn_cast<ReturnInst>((*I)->getTerminator())) {
BasicBlock *New = (*I)->splitBasicBlock(RI, (*I)->getName()+".ret");
if (DT) {
// Old dominates New. New node domiantes all other nodes dominated
//by Old.
DomTreeNode *OldNode = DT->getNode(*I);
std::vector<DomTreeNode *> Children;
for (DomTreeNode::iterator DI = OldNode->begin(), DE = OldNode->end();
DI != DE; ++DI)
Children.push_back(*DI);
DomTreeNode *NewNode = DT->addNewBlock(New, *I);
for (std::vector<DomTreeNode *>::iterator I = Children.begin(),
E = Children.end(); I != E; ++I)
DT->changeImmediateDominator(*I, NewNode);
}
}
}
// findInputsOutputs - Find inputs to, outputs from the code region.