[llvm] fc01c11 - [NFCI] Check for non-null before dereferencing a VPBB ptr (#190403)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 7 14:17:55 PDT 2026
Author: calebwat
Date: 2026-04-07T22:17:51+01:00
New Revision: fc01c111b94f43894b3099553bc0b0e42ef5de2c
URL: https://github.com/llvm/llvm-project/commit/fc01c111b94f43894b3099553bc0b0e42ef5de2c
DIFF: https://github.com/llvm/llvm-project/commit/fc01c111b94f43894b3099553bc0b0e42ef5de2c.diff
LOG: [NFCI] Check for non-null before dereferencing a VPBB ptr (#190403)
A VPBB variable is possibly null (defined via a ternary), but is
subsequently dereferenced without a check included. This patch adds a
check for it to avoid any possibly null dereference. This was found via
static analysis, there is not a known case right now where this issue is
hit.
Added:
Modified:
llvm/lib/Transforms/Vectorize/VPlanUtils.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/VPlanUtils.cpp b/llvm/lib/Transforms/Vectorize/VPlanUtils.cpp
index 04b6348665a05..e33a936dd9978 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanUtils.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanUtils.cpp
@@ -402,18 +402,19 @@ bool vputils::isUniformAcrossVFsAndUFs(VPValue *V) {
VPRecipeBase *R = V->getDefiningRecipe();
VPBasicBlock *VPBB = R ? R->getParent() : nullptr;
VPlan *Plan = VPBB ? VPBB->getPlan() : nullptr;
- if (VPBB &&
- (VPBB == Plan->getVectorPreheader() || VPBB == Plan->getEntry())) {
- if (match(V->getDefiningRecipe(),
- m_VPInstruction<VPInstruction::CanonicalIVIncrementForPart>()))
- return false;
- return all_of(R->operands(), isUniformAcrossVFsAndUFs);
- }
+ if (VPBB) {
+ if ((VPBB == Plan->getVectorPreheader() || VPBB == Plan->getEntry())) {
+ if (match(V->getDefiningRecipe(),
+ m_VPInstruction<VPInstruction::CanonicalIVIncrementForPart>()))
+ return false;
+ return all_of(R->operands(), isUniformAcrossVFsAndUFs);
+ }
- if (VPRegionBlock *EnclosingRegion = VPBB->getEnclosingLoopRegion()) {
- // Canonical IV is uniform.
- if (V == EnclosingRegion->getCanonicalIV())
- return true;
+ if (VPRegionBlock *EnclosingRegion = VPBB->getEnclosingLoopRegion()) {
+ // Canonical IV is uniform.
+ if (V == EnclosingRegion->getCanonicalIV())
+ return true;
+ }
}
return TypeSwitch<const VPRecipeBase *, bool>(R)
More information about the llvm-commits
mailing list