[llvm] 5f4549c - [SystemZ] lowerDYNAMIC_STACKALLOC_XPLINK - use cast<> instead of dyn_cast<> to avoid dereference of nullptr

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 17 03:56:37 PST 2022


Author: Simon Pilgrim
Date: 2022-02-17T11:56:29Z
New Revision: 5f4549c372676840a70dba455fea6b44c83391d6

URL: https://github.com/llvm/llvm-project/commit/5f4549c372676840a70dba455fea6b44c83391d6
DIFF: https://github.com/llvm/llvm-project/commit/5f4549c372676840a70dba455fea6b44c83391d6.diff

LOG: [SystemZ] lowerDYNAMIC_STACKALLOC_XPLINK - use cast<> instead of dyn_cast<> to avoid dereference of nullptr

The pointer is always dereferenced, so assert the cast is correct instead of returning nullptr

Added: 
    

Modified: 
    llvm/lib/Target/SystemZ/SystemZISelLowering.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
index 0eded62347bee..7fc3e33309830 100644
--- a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
@@ -3577,7 +3577,7 @@ SystemZTargetLowering::lowerDYNAMIC_STACKALLOC_XPLINK(SDValue Op,
   // If user has set the no alignment function attribute, ignore
   // alloca alignments.
   uint64_t AlignVal =
-      (RealignOpt ? dyn_cast<ConstantSDNode>(Align)->getZExtValue() : 0);
+      (RealignOpt ? cast<ConstantSDNode>(Align)->getZExtValue() : 0);
 
   uint64_t StackAlign = TFI->getStackAlignment();
   uint64_t RequiredAlign = std::max(AlignVal, StackAlign);


        


More information about the llvm-commits mailing list