[llvm] 83be69c - [VPlan][Coverity] Fix coverity CID1579964. (#121805)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 13 12:29:55 PST 2025
Author: offsake
Date: 2025-01-13T20:29:51Z
New Revision: 83be69cf9ade7e1f78df297518b1490d54794edc
URL: https://github.com/llvm/llvm-project/commit/83be69cf9ade7e1f78df297518b1490d54794edc
DIFF: https://github.com/llvm/llvm-project/commit/83be69cf9ade7e1f78df297518b1490d54794edc.diff
LOG: [VPlan][Coverity] Fix coverity CID1579964. (#121805)
Fix for the Coverity hit with CID1579964 in VPlan.cpp.
Coverity message with some context follows.
[Cov] var_compare_op: Comparing TermBr to null implies that TermBr might
be null.
434 } else if (TermBr && !TermBr->isConditional()) {
435 TermBr->setSuccessor(0, NewBB);
436 } else {
437 // Set each forward successor here when it is created, excluding
438 // backedges. A backward successor is set when the branch is
created.
439 unsigned idx = PredVPSuccessors.front() == this ? 0 : 1;
[Cov] CID 1579964: (#1 of 1): Dereference after null check
(FORWARD_NULL)
[Cov] var_deref_model: Passing null pointer TermBr to getSuccessor,
which dereferences it.
Added:
Modified:
llvm/lib/Transforms/Vectorize/VPlan.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.cpp b/llvm/lib/Transforms/Vectorize/VPlan.cpp
index e804f81c36dba0..aa41c41e90c4c4 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlan.cpp
@@ -438,10 +438,10 @@ void VPBasicBlock::connectToPredecessors(VPTransformState::CFGState &CFG) {
// Set each forward successor here when it is created, excluding
// backedges. A backward successor is set when the branch is created.
unsigned idx = PredVPSuccessors.front() == this ? 0 : 1;
- assert(
- (!TermBr->getSuccessor(idx) ||
- (isa<VPIRBasicBlock>(this) && TermBr->getSuccessor(idx) == NewBB)) &&
- "Trying to reset an existing successor block.");
+ assert((TermBr && (!TermBr->getSuccessor(idx) ||
+ (isa<VPIRBasicBlock>(this) &&
+ TermBr->getSuccessor(idx) == NewBB))) &&
+ "Trying to reset an existing successor block.");
TermBr->setSuccessor(idx, NewBB);
}
CFG.DTU.applyUpdates({{DominatorTree::Insert, PredBB, NewBB}});
More information about the llvm-commits
mailing list