Skip to content

Commit f96bc61

Browse files
committed
[VPlan] Add extra checks for LoopForBB. NFC.
Adding the checks for LoopForBB not being nullptr before try to dereference it.
1 parent 9ed772c commit f96bc61

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

llvm/lib/Transforms/Vectorize/VPlanHCFGBuilder.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ void PlainCFGBuilder::buildPlainCFG(
379379
VPRegionBlock *Region = VPBB->getParent();
380380
Loop *LoopForBB = LI->getLoopFor(BB);
381381
// Set VPBB predecessors in the same order as they are in the incoming BB.
382-
if (!isHeaderBB(BB, LoopForBB)) {
382+
if (LoopForBB && !isHeaderBB(BB, LoopForBB)) {
383383
setVPBBPredsFromBB(VPBB, BB);
384384
} else if (Region) {
385385
// BB is a loop header and there's a corresponding region, set the
@@ -390,7 +390,7 @@ void PlainCFGBuilder::buildPlainCFG(
390390
// Create VPInstructions for BB.
391391
createVPInstructionsForVPBB(VPBB, BB);
392392

393-
if (BB == TheLoop->getLoopLatch()) {
393+
if (LoopForBB && BB == TheLoop->getLoopLatch()) {
394394
VPBasicBlock *HeaderVPBB = getOrCreateVPBB(LoopForBB->getHeader());
395395
VPBlockUtils::connectBlocks(VPBB, HeaderVPBB);
396396
continue;
@@ -423,7 +423,7 @@ void PlainCFGBuilder::buildPlainCFG(
423423
BasicBlock *IRSucc1 = BI->getSuccessor(1);
424424
VPBasicBlock *Successor0 = getOrCreateVPBB(IRSucc0);
425425
VPBasicBlock *Successor1 = getOrCreateVPBB(IRSucc1);
426-
if (BB == LoopForBB->getLoopLatch()) {
426+
if (LoopForBB && BB == LoopForBB->getLoopLatch()) {
427427
// For a latch we need to set the successor of the region rather than that
428428
// of VPBB and it should be set to the exit, i.e., non-header successor,
429429
// except for the top region, which is handled elsewhere.

0 commit comments

Comments
 (0)