Implement support for code extracting basic blocks that have a return
instruction in them. llvm-svn: 13490
This commit is contained in:
parent
795c9933e2
commit
13d2ddfe9c
|
@ -77,6 +77,7 @@ namespace {
|
||||||
}
|
}
|
||||||
|
|
||||||
void severSplitPHINodes(BasicBlock *&Header);
|
void severSplitPHINodes(BasicBlock *&Header);
|
||||||
|
void splitReturnBlocks();
|
||||||
void findInputsOutputs(Values &inputs, Values &outputs);
|
void findInputsOutputs(Values &inputs, Values &outputs);
|
||||||
|
|
||||||
Function *constructFunction(const Values &inputs,
|
Function *constructFunction(const Values &inputs,
|
||||||
|
@ -184,8 +185,13 @@ void CodeExtractor::severSplitPHINodes(BasicBlock *&Header) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
verifyFunction(*NewBB->getParent());
|
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");
|
||||||
}
|
}
|
||||||
|
|
||||||
// findInputsOutputs - Find inputs to, outputs from the code region.
|
// findInputsOutputs - Find inputs to, outputs from the code region.
|
||||||
|
@ -596,9 +602,13 @@ Function *CodeExtractor::ExtractCodeRegion(const std::vector<BasicBlock*> &code)
|
||||||
"No blocks in this region may have entries from outside the region"
|
"No blocks in this region may have entries from outside the region"
|
||||||
" except for the first block!");
|
" except for the first block!");
|
||||||
|
|
||||||
// If we have to split PHI nodes, do so now.
|
// If we have to split PHI nodes or the entry block, do so now.
|
||||||
severSplitPHINodes(header);
|
severSplitPHINodes(header);
|
||||||
|
|
||||||
|
// If we have any return instructions in the region, split those blocks so
|
||||||
|
// that the return is not in the region.
|
||||||
|
splitReturnBlocks();
|
||||||
|
|
||||||
Function *oldFunction = header->getParent();
|
Function *oldFunction = header->getParent();
|
||||||
|
|
||||||
// This takes place of the original loop
|
// This takes place of the original loop
|
||||||
|
|
Loading…
Reference in New Issue