[llvm] [VPlan][Coverity] Fix coverity CID1579964. (PR #121805)

via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 6 11:32:31 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-transforms

Author: None (offsake)

<details>
<summary>Changes</summary>

Fix for the Coverity hit with CID1579964 in VPlan.cpp.


---
Full diff: https://github.com/llvm/llvm-project/pull/121805.diff


1 Files Affected:

- (modified) llvm/lib/Transforms/Vectorize/VPlan.cpp (+4-4) 


``````````diff
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}});

``````````

</details>


https://github.com/llvm/llvm-project/pull/121805


More information about the llvm-commits mailing list