diff options
author | Owen Anderson <resistor@mac.com> | 2009-08-24 23:32:14 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2009-08-24 23:32:14 +0000 |
commit | 9ea9fcdf654b9a54a072a3e28cb2091b6c84cf1c (patch) | |
tree | f71cccfae77b3188d9c6b08e0833aba1bf6f98ee /lib | |
parent | 838dbd92d8a4b979ec1d266884ebad55f6ae6998 (diff) | |
download | external_llvm-9ea9fcdf654b9a54a072a3e28cb2091b6c84cf1c.zip external_llvm-9ea9fcdf654b9a54a072a3e28cb2091b6c84cf1c.tar.gz external_llvm-9ea9fcdf654b9a54a072a3e28cb2091b6c84cf1c.tar.bz2 |
When extracting SEME regions of code, the extractor needs to update the dominator tree for split return blocks.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79957 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Transforms/Utils/CodeExtractor.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/lib/Transforms/Utils/CodeExtractor.cpp b/lib/Transforms/Utils/CodeExtractor.cpp index 0558bf0..73458ee 100644 --- a/lib/Transforms/Utils/CodeExtractor.cpp +++ b/lib/Transforms/Utils/CodeExtractor.cpp @@ -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. |