137137// /
138138// / KernelMemorySanitizer only supports X86_64 at the moment.
139139// /
140+ //
141+ // FIXME: This sanitizer does not yet handle scalable vectors
142+ //
140143// ===----------------------------------------------------------------------===//
141144
142145#include " llvm/Transforms/Instrumentation/MemorySanitizer.h"
@@ -1355,7 +1358,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
13551358 if (VectorType *VT = dyn_cast<VectorType>(OrigTy)) {
13561359 uint32_t EltSize = DL.getTypeSizeInBits (VT->getElementType ());
13571360 return FixedVectorType::get (IntegerType::get (*MS.C , EltSize),
1358- VT ->getNumElements ());
1361+ cast<FixedVectorType>(VT) ->getNumElements ());
13591362 }
13601363 if (ArrayType *AT = dyn_cast<ArrayType>(OrigTy)) {
13611364 return ArrayType::get (getShadowTy (AT->getElementType ()),
@@ -2077,7 +2080,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
20772080 size_t VectorOrPrimitiveTypeSizeInBits (Type *Ty) {
20782081 assert (!(Ty->isVectorTy () && Ty->getScalarType ()->isPointerTy ()) &&
20792082 " Vector of pointers is not a valid shadow type" );
2080- return Ty->isVectorTy () ? cast<VectorType >(Ty)->getNumElements () *
2083+ return Ty->isVectorTy () ? cast<FixedVectorType >(Ty)->getNumElements () *
20812084 Ty->getScalarSizeInBits ()
20822085 : Ty->getPrimitiveSizeInBits ();
20832086 }
@@ -2095,8 +2098,8 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
20952098 if (dstTy->isIntegerTy () && srcTy->isIntegerTy ())
20962099 return IRB.CreateIntCast (V, dstTy, Signed);
20972100 if (dstTy->isVectorTy () && srcTy->isVectorTy () &&
2098- cast<VectorType >(dstTy)->getNumElements () ==
2099- cast<VectorType >(srcTy)->getNumElements ())
2101+ cast<FixedVectorType >(dstTy)->getNumElements () ==
2102+ cast<FixedVectorType >(srcTy)->getNumElements ())
21002103 return IRB.CreateIntCast (V, dstTy, Signed);
21012104 Value *V1 = IRB.CreateBitCast (V, Type::getIntNTy (*MS.C , srcSizeInBits));
21022105 Value *V2 =
@@ -2141,7 +2144,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
21412144 Constant *ShadowMul;
21422145 Type *Ty = ConstArg->getType ();
21432146 if (auto *VTy = dyn_cast<VectorType>(Ty)) {
2144- unsigned NumElements = VTy->getNumElements ();
2147+ unsigned NumElements = cast<FixedVectorType>( VTy) ->getNumElements ();
21452148 Type *EltTy = VTy->getElementType ();
21462149 SmallVector<Constant *, 16 > Elements;
21472150 for (unsigned Idx = 0 ; Idx < NumElements; ++Idx) {
@@ -2969,8 +2972,8 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
29692972
29702973 Value *Acc = IRB.CreateExtractElement (
29712974 MaskedPassThruShadow, ConstantInt::get (IRB.getInt32Ty (), 0 ));
2972- for (int i = 1 ,
2973- N = cast<VectorType>(PassThru-> getType ()) ->getNumElements ();
2975+ for (int i = 1 , N = cast<FixedVectorType>(PassThru-> getType ())
2976+ ->getNumElements ();
29742977 i < N; ++i) {
29752978 Value *More = IRB.CreateExtractElement (
29762979 MaskedPassThruShadow, ConstantInt::get (IRB.getInt32Ty (), i));
@@ -3030,7 +3033,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
30303033 IRBuilder<> IRB (&I);
30313034 Type *ShadowTy = getShadowTy (&I);
30323035 unsigned Width =
3033- cast<VectorType >(I.getArgOperand (0 )->getType ())->getNumElements ();
3036+ cast<FixedVectorType >(I.getArgOperand (0 )->getType ())->getNumElements ();
30343037 assert (isa<ConstantInt>(I.getArgOperand (2 )) &&
30353038 " pclmul 3rd operand must be a constant" );
30363039 unsigned Imm = cast<ConstantInt>(I.getArgOperand (2 ))->getZExtValue ();
0 commit comments