[llvm] f991a16 - [CodeGen] ExpandLargeFpConvert - don't dereference a dyn_cast result

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 13 03:26:52 PDT 2024


Author: Simon Pilgrim
Date: 2024-06-13T11:24:58+01:00
New Revision: f991a16735c6a032f6b3ae0817a421ef94d705ca

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

LOG: [CodeGen] ExpandLargeFpConvert - don't dereference a dyn_cast result

dyn_cast is allowed to return NULL - use cast<> to assert that the cast type is valid

Fixes static analysis warning.

Added: 
    

Modified: 
    llvm/lib/CodeGen/ExpandLargeFpConvert.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/ExpandLargeFpConvert.cpp b/llvm/lib/CodeGen/ExpandLargeFpConvert.cpp
index 938dda37b9f63..11f123aa5bed8 100644
--- a/llvm/lib/CodeGen/ExpandLargeFpConvert.cpp
+++ b/llvm/lib/CodeGen/ExpandLargeFpConvert.cpp
@@ -611,7 +611,7 @@ static bool runImpl(Function &F, const TargetLowering &TLI) {
       if (I.getOperand(0)->getType()->isScalableTy())
         continue;
 
-      auto *IntTy = dyn_cast<IntegerType>(I.getType()->getScalarType());
+      auto *IntTy = cast<IntegerType>(I.getType()->getScalarType());
       if (IntTy->getIntegerBitWidth() <= MaxLegalFpConvertBitWidth)
         continue;
 
@@ -629,7 +629,7 @@ static bool runImpl(Function &F, const TargetLowering &TLI) {
         continue;
 
       auto *IntTy =
-          dyn_cast<IntegerType>(I.getOperand(0)->getType()->getScalarType());
+          cast<IntegerType>(I.getOperand(0)->getType()->getScalarType());
       if (IntTy->getIntegerBitWidth() <= MaxLegalFpConvertBitWidth)
         continue;
 


        


More information about the llvm-commits mailing list