[llvm] 7104f0c - [Hexagon] aligned load/store patterns - use cast<> instead of dyn_cast<> to avoid dereference of nullptr

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 18 02:36:48 PST 2022


Author: Simon Pilgrim
Date: 2022-02-18T10:36:40Z
New Revision: 7104f0c4ab53b0feaf204b942576afdf2106b75b

URL: https://github.com/llvm/llvm-project/commit/7104f0c4ab53b0feaf204b942576afdf2106b75b
DIFF: https://github.com/llvm/llvm-project/commit/7104f0c4ab53b0feaf204b942576afdf2106b75b.diff

LOG: [Hexagon] aligned load/store patterns - use cast<> instead of dyn_cast<> to avoid dereference of nullptr

The pointer is always referenced inside isAlignedMemNode, so assert the cast is correct instead of returning nullptr

Added: 
    

Modified: 
    llvm/lib/Target/Hexagon/HexagonPatternsHVX.td

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/Hexagon/HexagonPatternsHVX.td b/llvm/lib/Target/Hexagon/HexagonPatternsHVX.td
index bdd46cfe7152..6769548d6cbc 100644
--- a/llvm/lib/Target/Hexagon/HexagonPatternsHVX.td
+++ b/llvm/lib/Target/Hexagon/HexagonPatternsHVX.td
@@ -92,19 +92,19 @@ def IsVecOff : PatLeaf<(i32 imm), [{
 
 
 def alignedload: PatFrag<(ops node:$a), (load $a), [{
-  return isAlignedMemNode(dyn_cast<MemSDNode>(N));
+  return isAlignedMemNode(cast<MemSDNode>(N));
 }]>;
 
 def unalignedload: PatFrag<(ops node:$a), (load $a), [{
-  return !isAlignedMemNode(dyn_cast<MemSDNode>(N));
+  return !isAlignedMemNode(cast<MemSDNode>(N));
 }]>;
 
 def alignedstore: PatFrag<(ops node:$v, node:$a), (store $v, $a), [{
-  return isAlignedMemNode(dyn_cast<MemSDNode>(N));
+  return isAlignedMemNode(cast<MemSDNode>(N));
 }]>;
 
 def unalignedstore: PatFrag<(ops node:$v, node:$a), (store $v, $a), [{
-  return !isAlignedMemNode(dyn_cast<MemSDNode>(N));
+  return !isAlignedMemNode(cast<MemSDNode>(N));
 }]>;
 
 


        


More information about the llvm-commits mailing list