forked from OSchip/llvm-project
[BasicBlockUtils] Check for nullptr before updating LoopInfo.
LoopInfo::getLoopFor returns nullptr if a BB is not in a loop and only then can the loop be updated to contain the newly created BBs. Add the missing nullptr check to SplitBlockAndInsertIfThen. Within LLVM, the only user of this function that also passes a LoopInfo to be updated is InnerLoopVectorizer::predicateInstructions(). As the method's name implies, the BB operataten on will always be within a loop, but out-of-tree users may also use it differently (here: Polly). All other uses of LoopInfo::getLoopFor in the file properly check its return value for nullptr. llvm-svn: 297016
This commit is contained in:
parent
6b029a5380
commit
811de8a619
|
@ -646,9 +646,10 @@ llvm::SplitBlockAndInsertIfThen(Value *Cond, Instruction *SplitBefore,
|
|||
}
|
||||
|
||||
if (LI) {
|
||||
Loop *L = LI->getLoopFor(Head);
|
||||
L->addBasicBlockToLoop(ThenBlock, *LI);
|
||||
L->addBasicBlockToLoop(Tail, *LI);
|
||||
if (Loop *L = LI->getLoopFor(Head)) {
|
||||
L->addBasicBlockToLoop(ThenBlock, *LI);
|
||||
L->addBasicBlockToLoop(Tail, *LI);
|
||||
}
|
||||
}
|
||||
|
||||
return CheckTerm;
|
||||
|
|
Loading…
Reference in New Issue