From: Philip Reames Date: Mon, 13 Mar 2023 20:05:53 +0000 (-0700) Subject: [MSAN] Remove usage of FixedVectorType where trivial [nfc] X-Git-Tag: upstream/17.0.6~14982 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a8355772690f47215935106567ec77f6d24f06c9;p=platform%2Fupstream%2Fllvm.git [MSAN] Remove usage of FixedVectorType where trivial [nfc] This is a prepass on generalizing for scalable vectors; I'm just picking off the easy bits. --- diff --git a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp index 23c85ca..9e98cef 100644 --- a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp @@ -1505,8 +1505,8 @@ struct MemorySanitizerVisitor : public InstVisitor { const DataLayout &DL = F.getParent()->getDataLayout(); if (VectorType *VT = dyn_cast(OrigTy)) { uint32_t EltSize = DL.getTypeSizeInBits(VT->getElementType()); - return FixedVectorType::get(IntegerType::get(*MS.C, EltSize), - cast(VT)->getNumElements()); + return VectorType::get(IntegerType::get(*MS.C, EltSize), + VT->getElementCount()); } if (ArrayType *AT = dyn_cast(OrigTy)) { return ArrayType::get(getShadowTy(AT->getElementType()), @@ -1597,28 +1597,28 @@ struct MemorySanitizerVisitor : public InstVisitor { } Type *ptrToIntPtrType(Type *PtrTy) const { - if (FixedVectorType *VectTy = dyn_cast(PtrTy)) { - return FixedVectorType::get(ptrToIntPtrType(VectTy->getElementType()), - VectTy->getNumElements()); + if (VectorType *VectTy = dyn_cast(PtrTy)) { + return VectorType::get(ptrToIntPtrType(VectTy->getElementType()), + VectTy->getElementCount()); } assert(PtrTy->isIntOrPtrTy()); return MS.IntptrTy; } Type *getPtrToShadowPtrType(Type *IntPtrTy, Type *ShadowTy) const { - if (FixedVectorType *VectTy = dyn_cast(IntPtrTy)) { - return FixedVectorType::get( + if (VectorType *VectTy = dyn_cast(IntPtrTy)) { + return VectorType::get( getPtrToShadowPtrType(VectTy->getElementType(), ShadowTy), - VectTy->getNumElements()); + VectTy->getElementCount()); } assert(IntPtrTy == MS.IntptrTy); return ShadowTy->getPointerTo(); } Constant *constToIntPtr(Type *IntPtrTy, uint64_t C) const { - if (FixedVectorType *VectTy = dyn_cast(IntPtrTy)) { - return ConstantDataVector::getSplat( - VectTy->getNumElements(), constToIntPtr(VectTy->getElementType(), C)); + if (VectorType *VectTy = dyn_cast(IntPtrTy)) { + return ConstantVector::getSplat( + VectTy->getElementCount(), constToIntPtr(VectTy->getElementType(), C)); } assert(IntPtrTy == MS.IntptrTy); return ConstantInt::get(MS.IntptrTy, C); @@ -2434,8 +2434,8 @@ struct MemorySanitizerVisitor : public InstVisitor { if (dstTy->isIntegerTy() && srcTy->isIntegerTy()) return IRB.CreateIntCast(V, dstTy, Signed); if (dstTy->isVectorTy() && srcTy->isVectorTy() && - cast(dstTy)->getNumElements() == - cast(srcTy)->getNumElements()) + cast(dstTy)->getElementCount() == + cast(srcTy)->getElementCount()) return IRB.CreateIntCast(V, dstTy, Signed); Value *V1 = IRB.CreateBitCast(V, Type::getIntNTy(*MS.C, srcSizeInBits)); Value *V2 = @@ -3356,7 +3356,7 @@ struct MemorySanitizerVisitor : public InstVisitor { } Type *ShadowTy = getShadowTy(&I); - Type *ElementShadowTy = cast(ShadowTy)->getElementType(); + Type *ElementShadowTy = cast(ShadowTy)->getElementType(); auto [ShadowPtr, OriginPtr] = getShadowOriginPtr(Ptr, IRB, ElementShadowTy, {}, /*isStore*/ false); @@ -3382,7 +3382,7 @@ struct MemorySanitizerVisitor : public InstVisitor { Value *Shadow = getShadow(Values); Type *ElementShadowTy = - getShadowTy(cast(Values->getType())->getElementType()); + getShadowTy(cast(Values->getType())->getElementType()); auto [ShadowPtr, OriginPtrs] = getShadowOriginPtr(Ptr, IRB, ElementShadowTy, {}, /*isStore*/ true); @@ -3415,7 +3415,7 @@ struct MemorySanitizerVisitor : public InstVisitor { } Type *ShadowTy = getShadowTy(&I); - Type *ElementShadowTy = cast(ShadowTy)->getElementType(); + Type *ElementShadowTy = cast(ShadowTy)->getElementType(); auto [ShadowPtrs, OriginPtrs] = getShadowOriginPtr( Ptrs, IRB, ElementShadowTy, Alignment, /*isStore*/ false); @@ -3448,7 +3448,7 @@ struct MemorySanitizerVisitor : public InstVisitor { Value *Shadow = getShadow(Values); Type *ElementShadowTy = - getShadowTy(cast(Values->getType())->getElementType()); + getShadowTy(cast(Values->getType())->getElementType()); auto [ShadowPtrs, OriginPtrs] = getShadowOriginPtr( Ptrs, IRB, ElementShadowTy, Alignment, /*isStore*/ true);