Skip to content

Commit 3e1ff6d

Browse files
committed
[VPlan][NFCI] Small code quality fixes in VPlanHCFGBuilder and VPlanSLP
Addresses some code quality issues found during an internal code review. Specifically, marking implicitly defined copy constructor and copy assignment for VPInterleavedAccessInfo as delete in VPlanSLP.h, and fixing two instances where null dereferences were technically possible in VPlanHCFGBuilder.cpp.
1 parent 554859c commit 3e1ff6d

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

llvm/lib/Transforms/Vectorize/VPlanHCFGBuilder.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ void PlainCFGBuilder::buildPlainCFG(
378378
VPBasicBlock *VPBB = getOrCreateVPBB(BB);
379379
VPRegionBlock *Region = VPBB->getParent();
380380
Loop *LoopForBB = LI->getLoopFor(BB);
381+
assert(LoopForBB && "Expected block to be inside a loop");
381382
// Set VPBB predecessors in the same order as they are in the incoming BB.
382383
if (!isHeaderBB(BB, LoopForBB)) {
383384
setVPBBPredsFromBB(VPBB, BB);
@@ -423,7 +424,7 @@ void PlainCFGBuilder::buildPlainCFG(
423424
BasicBlock *IRSucc1 = BI->getSuccessor(1);
424425
VPBasicBlock *Successor0 = getOrCreateVPBB(IRSucc0);
425426
VPBasicBlock *Successor1 = getOrCreateVPBB(IRSucc1);
426-
if (BB == LoopForBB->getLoopLatch()) {
427+
if (BB == LoopForBB->getLoopLatch() && Region) {
427428
// For a latch we need to set the successor of the region rather than that
428429
// of VPBB and it should be set to the exit, i.e., non-header successor,
429430
// except for the top region, which is handled elsewhere.
@@ -437,15 +438,13 @@ void PlainCFGBuilder::buildPlainCFG(
437438

438439
// Don't connect any blocks outside the current loop except the latch for
439440
// now. The latch is handled above.
440-
if (LoopForBB) {
441-
if (!LoopForBB->contains(IRSucc0)) {
442-
VPBB->setOneSuccessor(Successor1);
443-
continue;
444-
}
445-
if (!LoopForBB->contains(IRSucc1)) {
446-
VPBB->setOneSuccessor(Successor0);
447-
continue;
448-
}
441+
if (!LoopForBB->contains(IRSucc0)) {
442+
VPBB->setOneSuccessor(Successor1);
443+
continue;
444+
}
445+
if (!LoopForBB->contains(IRSucc1)) {
446+
VPBB->setOneSuccessor(Successor0);
447+
continue;
449448
}
450449

451450
VPBB->setTwoSuccessors(Successor0, Successor1);

llvm/lib/Transforms/Vectorize/VPlanSLP.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ class VPInterleavedAccessInfo {
4848

4949
public:
5050
VPInterleavedAccessInfo(VPlan &Plan, InterleavedAccessInfo &IAI);
51+
VPInterleavedAccessInfo(const VPInterleavedAccessInfo &) = delete;
52+
VPInterleavedAccessInfo &operator=(const VPInterleavedAccessInfo &) = delete;
5153

5254
~VPInterleavedAccessInfo() {
5355
// Avoid releasing a pointer twice.

0 commit comments

Comments
 (0)