[llvm] 37ebec6 - [MIPS] Mips16DAGToDAGISel::selectAddr - Use cast<> instead of dyn_cast<> to avoid dereference of nullptr
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 13 03:11:37 PST 2022
Author: Simon Pilgrim
Date: 2022-01-13T11:10:49Z
New Revision: 37ebec68a828e205137c9202da16804b2736e5d5
URL: https://github.com/llvm/llvm-project/commit/37ebec68a828e205137c9202da16804b2736e5d5
DIFF: https://github.com/llvm/llvm-project/commit/37ebec68a828e205137c9202da16804b2736e5d5.diff
LOG: [MIPS] Mips16DAGToDAGISel::selectAddr - Use cast<> instead of dyn_cast<> to avoid dereference of nullptr
The pointer is always dereferenced immediately below, so assert the cast is correct instead of returning nullptr
Added:
Modified:
llvm/lib/Target/Mips/Mips16ISelDAGToDAG.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/Mips/Mips16ISelDAGToDAG.cpp b/llvm/lib/Target/Mips/Mips16ISelDAGToDAG.cpp
index ddd28d095e513..50147c019bfd5 100644
--- a/llvm/lib/Target/Mips/Mips16ISelDAGToDAG.cpp
+++ b/llvm/lib/Target/Mips/Mips16ISelDAGToDAG.cpp
@@ -121,7 +121,7 @@ bool Mips16DAGToDAGISel::selectAddr(bool SPAllowed, SDValue Addr, SDValue &Base,
}
// Addresses of the form FI+const or FI|const
if (CurDAG->isBaseWithConstantOffset(Addr)) {
- ConstantSDNode *CN = dyn_cast<ConstantSDNode>(Addr.getOperand(1));
+ auto *CN = cast<ConstantSDNode>(Addr.getOperand(1));
if (isInt<16>(CN->getSExtValue())) {
// If the first operand is a FI, get the TargetFI Node
if (SPAllowed) {
More information about the llvm-commits
mailing list