llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang-codegen

Author: None (smanna12)

<details>
<summary>Changes</summary>

This patch replaces dyn_cast&lt;&gt; with cast&lt;&gt; for obtaining 
ScalableVectorType pointers in the EmitSVETupleSetOrGet() and 
EmitSVETupleCreate() functions to ensure that the code expects valid 
ScalableVectorType instances and will cause an assertion if the cast is 
invalid, preventing possible null pointer dereferences and improving codes 
safety.

---
Full diff: https://github.com/llvm/llvm-project/pull/94267.diff


1 Files Affected:

- (modified) clang/lib/CodeGen/CGBuiltin.cpp (+2-2) 


``````````diff
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 37d0c478e0330..3ba9f4693170f 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -10211,7 +10211,7 @@ Value *CodeGenFunction::EmitSVETupleSetOrGet(const 
SVETypeFlags &TypeFlags,
          "Expects TypleFlag isTupleSet or TypeFlags.isTupleSet()");
 
   unsigned I = cast<ConstantInt>(Ops[1])->getSExtValue();
-  auto *SingleVecTy = dyn_cast<llvm::ScalableVectorType>(
+  auto *SingleVecTy = cast<llvm::ScalableVectorType>(
                       TypeFlags.isTupleSet() ? Ops[2]->getType() : Ty);
   Value *Idx = ConstantInt::get(CGM.Int64Ty,
                                 I * SingleVecTy->getMinNumElements());
@@ -10226,7 +10226,7 @@ Value *CodeGenFunction::EmitSVETupleCreate(const 
SVETypeFlags &TypeFlags,
                                              ArrayRef<Value *> Ops) {
   assert(TypeFlags.isTupleCreate() && "Expects TypleFlag isTupleCreate");
 
-  auto *SrcTy = dyn_cast<llvm::ScalableVectorType>(Ops[0]->getType());
+  auto *SrcTy = cast<llvm::ScalableVectorType>(Ops[0]->getType());
   unsigned MinElts = SrcTy->getMinNumElements();
   Value *Call = llvm::PoisonValue::get(Ty);
   for (unsigned I = 0; I < Ops.size(); I++) {

``````````

</details>


https://github.com/llvm/llvm-project/pull/94267
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to