[clang] [Clang] Prevent null pointer dereferences in SVE tuple functions (PR #94267)

via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 5 07:00:13 PDT 2024


================
@@ -10211,8 +10211,8 @@ 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>(
-                      TypeFlags.isTupleSet() ? Ops[2]->getType() : Ty);
+  auto *SingleVecTy = cast<llvm::ScalableVectorType>(
----------------
CarolineConcatto wrote:

I am not sure we want the compile to crash  that way, at least that is my impression.
Should this be an if  statement
if(auto *SingleVecTy = cast<llvm::ScalableVectorType>....){
value *Idx = ConstantInt::get(CGM.Int64Ty,
                                I * SingleVecTy->getMinNumElements());
}
Is it possible to add a test for this change too?

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


More information about the cfe-commits mailing list