diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp --- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -1513,9 +1513,10 @@ unsigned Granularity, uint32_t TypeSize, bool IsWrite, Value *SizeArgument, bool UseCalls, uint32_t Exp) { - auto *VTy = cast(Addr->getType())->getElementType(); + auto *VTy = + cast(cast(Addr->getType())->getElementType()); uint64_t ElemTypeSize = DL.getTypeStoreSizeInBits(VTy->getScalarType()); - unsigned Num = VTy->getVectorNumElements(); + unsigned Num = VTy->getNumElements(); auto Zero = ConstantInt::get(IntptrTy, 0); for (unsigned Idx = 0; Idx < Num; ++Idx) { Value *InstrumentedAddress = nullptr; diff --git a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp --- a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp @@ -2068,9 +2068,9 @@ size_t VectorOrPrimitiveTypeSizeInBits(Type *Ty) { assert(!(Ty->isVectorTy() && Ty->getScalarType()->isPointerTy()) && "Vector of pointers is not a valid shadow type"); - return Ty->isVectorTy() ? - Ty->getVectorNumElements() * Ty->getScalarSizeInBits() : - Ty->getPrimitiveSizeInBits(); + return Ty->isVectorTy() ? cast(Ty)->getNumElements() * + Ty->getScalarSizeInBits() + : Ty->getPrimitiveSizeInBits(); } /// Cast between two shadow types, extending or truncating as @@ -2086,7 +2086,8 @@ if (dstTy->isIntegerTy() && srcTy->isIntegerTy()) return IRB.CreateIntCast(V, dstTy, Signed); if (dstTy->isVectorTy() && srcTy->isVectorTy() && - dstTy->getVectorNumElements() == srcTy->getVectorNumElements()) + cast(dstTy)->getNumElements() == + cast(srcTy)->getNumElements()) return IRB.CreateIntCast(V, dstTy, Signed); Value *V1 = IRB.CreateBitCast(V, Type::getIntNTy(*MS.C, srcSizeInBits)); Value *V2 = @@ -2130,9 +2131,9 @@ Value *OtherArg) { Constant *ShadowMul; Type *Ty = ConstArg->getType(); - if (Ty->isVectorTy()) { - unsigned NumElements = Ty->getVectorNumElements(); - Type *EltTy = Ty->getSequentialElementType(); + if (auto *VTy = dyn_cast(Ty)) { + unsigned NumElements = VTy->getNumElements(); + Type *EltTy = VTy->getElementType(); SmallVector Elements; for (unsigned Idx = 0; Idx < NumElements; ++Idx) { if (ConstantInt *Elt = @@ -2657,7 +2658,7 @@ assert(CopyOp->getType() == I.getType()); assert(CopyOp->getType()->isVectorTy()); Value *ResultShadow = getShadow(CopyOp); - Type *EltTy = ResultShadow->getType()->getVectorElementType(); + Type *EltTy = cast(ResultShadow->getType())->getElementType(); for (int i = 0; i < NumUsedElements; ++i) { ResultShadow = IRB.CreateInsertElement( ResultShadow, ConstantInt::getNullValue(EltTy), @@ -2959,8 +2960,9 @@ Value *Acc = IRB.CreateExtractElement( MaskedPassThruShadow, ConstantInt::get(IRB.getInt32Ty(), 0)); - for (int i = 1, N = PassThru->getType()->getVectorNumElements(); i < N; - ++i) { + for (int i = 1, + N = cast(PassThru->getType())->getNumElements(); + i < N; ++i) { Value *More = IRB.CreateExtractElement( MaskedPassThruShadow, ConstantInt::get(IRB.getInt32Ty(), i)); Acc = IRB.CreateOr(Acc, More); @@ -3020,7 +3022,8 @@ void handlePclmulIntrinsic(IntrinsicInst &I) { IRBuilder<> IRB(&I); Type *ShadowTy = getShadowTy(&I); - unsigned Width = I.getArgOperand(0)->getType()->getVectorNumElements(); + unsigned Width = + cast(I.getArgOperand(0)->getType())->getNumElements(); assert(isa(I.getArgOperand(2)) && "pclmul 3rd operand must be a constant"); unsigned Imm = cast(I.getArgOperand(2))->getZExtValue(); diff --git a/llvm/lib/Transforms/Instrumentation/PoisonChecking.cpp b/llvm/lib/Transforms/Instrumentation/PoisonChecking.cpp --- a/llvm/lib/Transforms/Instrumentation/PoisonChecking.cpp +++ b/llvm/lib/Transforms/Instrumentation/PoisonChecking.cpp @@ -195,10 +195,11 @@ break; case Instruction::ExtractElement: { Value *Vec = I.getOperand(0); - if (Vec->getType()->getVectorIsScalable()) + auto *VecVTy = cast(Vec->getType()); + if (VecVTy->isScalable()) break; Value *Idx = I.getOperand(1); - unsigned NumElts = Vec->getType()->getVectorNumElements(); + unsigned NumElts = VecVTy->getNumElements(); Value *Check = B.CreateICmp(ICmpInst::ICMP_UGE, Idx, ConstantInt::get(Idx->getType(), NumElts)); @@ -207,10 +208,11 @@ } case Instruction::InsertElement: { Value *Vec = I.getOperand(0); - if (Vec->getType()->getVectorIsScalable()) + auto *VecVTy = cast(Vec->getType()); + if (VecVTy->isScalable()) break; Value *Idx = I.getOperand(2); - unsigned NumElts = Vec->getType()->getVectorNumElements(); + unsigned NumElts = VecVTy->getNumElements(); Value *Check = B.CreateICmp(ICmpInst::ICMP_UGE, Idx, ConstantInt::get(Idx->getType(), NumElts));