[llvm] 3d7d246 - [RICSV] PerformDAGCombine - don't directly dereference dyn_cast results
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 27 04:30:14 PDT 2024
Author: Simon Pilgrim
Date: 2024-06-27T12:29:56+01:00
New Revision: 3d7d246977b4fdcdc7e601cc9dc0165a0558c4df
URL: https://github.com/llvm/llvm-project/commit/3d7d246977b4fdcdc7e601cc9dc0165a0558c4df
DIFF: https://github.com/llvm/llvm-project/commit/3d7d246977b4fdcdc7e601cc9dc0165a0558c4df.diff
LOG: [RICSV] PerformDAGCombine - don't directly dereference dyn_cast results
Use cast<> to assert the cast is valid to help avoid null dereferences
Fixes static analyser warnings
Added:
Modified:
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index 9e988783e2eb6..a648ee2c95713 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -16894,7 +16894,7 @@ SDValue RISCVTargetLowering::PerformDAGCombine(SDNode *N,
DAG.getNode(ISD::FNEG, DL, VT, NewFPExtRound));
}
case ISD::MGATHER: {
- const auto *MGN = dyn_cast<MaskedGatherSDNode>(N);
+ const auto *MGN = cast<MaskedGatherSDNode>(N);
const EVT VT = N->getValueType(0);
SDValue Index = MGN->getIndex();
SDValue ScaleOp = MGN->getScale();
@@ -16994,7 +16994,7 @@ SDValue RISCVTargetLowering::PerformDAGCombine(SDNode *N,
break;
}
case ISD::MSCATTER:{
- const auto *MSN = dyn_cast<MaskedScatterSDNode>(N);
+ const auto *MSN = cast<MaskedScatterSDNode>(N);
SDValue Index = MSN->getIndex();
SDValue ScaleOp = MSN->getScale();
ISD::MemIndexType IndexType = MSN->getIndexType();
@@ -17030,7 +17030,7 @@ SDValue RISCVTargetLowering::PerformDAGCombine(SDNode *N,
break;
}
case ISD::VP_GATHER: {
- const auto *VPGN = dyn_cast<VPGatherSDNode>(N);
+ const auto *VPGN = cast<VPGatherSDNode>(N);
SDValue Index = VPGN->getIndex();
SDValue ScaleOp = VPGN->getScale();
ISD::MemIndexType IndexType = VPGN->getIndexType();
@@ -17055,7 +17055,7 @@ SDValue RISCVTargetLowering::PerformDAGCombine(SDNode *N,
break;
}
case ISD::VP_SCATTER: {
- const auto *VPSN = dyn_cast<VPScatterSDNode>(N);
+ const auto *VPSN = cast<VPScatterSDNode>(N);
SDValue Index = VPSN->getIndex();
SDValue ScaleOp = VPSN->getScale();
ISD::MemIndexType IndexType = VPSN->getIndexType();
More information about the llvm-commits
mailing list