Skip to content

Commit bdcd200

Browse files
[SVE] Remove calls to VectorType::getNumElements from Instrumentation
Reviewers: efriedma, pcc, gchatelet, kmclaughlin, sdesmalen Reviewed By: sdesmalen Subscribers: tschuett, hiraditya, rkruppe, psnobl, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D82241
1 parent cf1d044 commit bdcd200

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
// Details of the algorithm:
1111
// https://github.com/google/sanitizers/wiki/AddressSanitizerAlgorithm
1212
//
13+
// FIXME: This sanitizer does not yet handle scalable vectors
14+
//
1315
//===----------------------------------------------------------------------===//
1416

1517
#include "llvm/Transforms/Instrumentation/AddressSanitizer.h"
@@ -1504,8 +1506,8 @@ static void instrumentMaskedLoadOrStore(AddressSanitizer *Pass,
15041506
unsigned Granularity, uint32_t TypeSize,
15051507
bool IsWrite, Value *SizeArgument,
15061508
bool UseCalls, uint32_t Exp) {
1507-
auto *VTy =
1508-
cast<VectorType>(cast<PointerType>(Addr->getType())->getElementType());
1509+
auto *VTy = cast<FixedVectorType>(
1510+
cast<PointerType>(Addr->getType())->getElementType());
15091511
uint64_t ElemTypeSize = DL.getTypeStoreSizeInBits(VTy->getScalarType());
15101512
unsigned Num = VTy->getNumElements();
15111513
auto Zero = ConstantInt::get(IntptrTy, 0);

llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@
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

Comments
 (0)