aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2011-08-24 18:07:01 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2011-08-24 18:07:01 +0000
commit605e2b518445d86491e1a0c812f7c85193d3517a (patch)
treed88d2f1136ea9e538596190354aecfa0550657c2 /lib
parentc7e0bb2325fac6b41f46e8b383119cc0da64a45b (diff)
downloadexternal_llvm-605e2b518445d86491e1a0c812f7c85193d3517a.zip
external_llvm-605e2b518445d86491e1a0c812f7c85193d3517a.tar.gz
external_llvm-605e2b518445d86491e1a0c812f7c85193d3517a.tar.bz2
Fix a crashing bug in SplitBlock when it is called on a block with no
dominator information even though dominators were previously computed. Patch by Nick Sumner. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138449 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Transforms/Utils/BasicBlockUtils.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/Transforms/Utils/BasicBlockUtils.cpp b/lib/Transforms/Utils/BasicBlockUtils.cpp
index 27120ee..a7f9efd 100644
--- a/lib/Transforms/Utils/BasicBlockUtils.cpp
+++ b/lib/Transforms/Utils/BasicBlockUtils.cpp
@@ -299,16 +299,17 @@ BasicBlock *llvm::SplitBlock(BasicBlock *Old, Instruction *SplitPt, Pass *P) {
if (DominatorTree *DT = P->getAnalysisIfAvailable<DominatorTree>()) {
// Old dominates New. New node dominates all other nodes dominated by Old.
- DomTreeNode *OldNode = DT->getNode(Old);
- std::vector<DomTreeNode *> Children;
- for (DomTreeNode::iterator I = OldNode->begin(), E = OldNode->end();
- I != E; ++I)
- Children.push_back(*I);
+ if (DomTreeNode *OldNode = DT->getNode(Old)) {
+ std::vector<DomTreeNode *> Children;
+ for (DomTreeNode::iterator I = OldNode->begin(), E = OldNode->end();
+ I != E; ++I)
+ Children.push_back(*I);
DomTreeNode *NewNode = DT->addNewBlock(New,Old);
for (std::vector<DomTreeNode *>::iterator I = Children.begin(),
E = Children.end(); I != E; ++I)
DT->changeImmediateDominator(*I, NewNode);
+ }
}
return New;