Verifier: Make sure masked load/store alignment is a power of 2

The same should also be done for scatter/gather, but the verifier
doesn't check those at all now.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@356094 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Matt Arsenault
2019-03-13 19:46:34 +00:00
parent 892b8f0cdb
commit 39c8bbd622
5 changed files with 28 additions and 4 deletions
+6 -2
View File
@@ -4500,11 +4500,13 @@ void Verifier::visitIntrinsicCall(Intrinsic::ID ID, CallBase &Call) {
Call);
Value *Ptr = Call.getArgOperand(0);
// Value *Alignment = Call.getArgOperand(1);
ConstantInt *Alignment = cast<ConstantInt>(Call.getArgOperand(1));
Value *Mask = Call.getArgOperand(2);
Value *PassThru = Call.getArgOperand(3);
Assert(Mask->getType()->isVectorTy(), "masked_load: mask must be vector",
Call);
Assert(Alignment->getValue().isPowerOf2(),
"masked_load: alignment must be a power of 2", Call);
// DataTy is the overloaded type
Type *DataTy = cast<PointerType>(Ptr->getType())->getElementType();
@@ -4520,10 +4522,12 @@ void Verifier::visitIntrinsicCall(Intrinsic::ID ID, CallBase &Call) {
case Intrinsic::masked_store: {
Value *Val = Call.getArgOperand(0);
Value *Ptr = Call.getArgOperand(1);
// Value *Alignment = Call.getArgOperand(2);
ConstantInt *Alignment = cast<ConstantInt>(Call.getArgOperand(2));
Value *Mask = Call.getArgOperand(3);
Assert(Mask->getType()->isVectorTy(), "masked_store: mask must be vector",
Call);
Assert(Alignment->getValue().isPowerOf2(),
"masked_store: alignment must be a power of 2", Call);
// DataTy is the overloaded type
Type *DataTy = cast<PointerType>(Ptr->getType())->getElementType();