[llvm] e914406 - [IRBuilder] Avoid fetching pointer element type in some assertions
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 3 03:53:06 PDT 2021
Author: Nikita Popov
Date: 2021-07-03T12:52:55+02:00
New Revision: e91440628e77bbde7065a40231b776e47f19beb8
URL: https://github.com/llvm/llvm-project/commit/e91440628e77bbde7065a40231b776e47f19beb8
DIFF: https://github.com/llvm/llvm-project/commit/e91440628e77bbde7065a40231b776e47f19beb8.diff
LOG: [IRBuilder] Avoid fetching pointer element type in some assertions
Specifically the CreateMaskedStore and CreateMaskedScatter APIs.
The CreateMaskedLoad and CreateMaskedGather APIs will need an
additional type argument.
Added:
Modified:
llvm/lib/IR/IRBuilder.cpp
Removed:
################################################################################
diff --git a/llvm/lib/IR/IRBuilder.cpp b/llvm/lib/IR/IRBuilder.cpp
index bcd41a5189bb..47b154c3cdc2 100644
--- a/llvm/lib/IR/IRBuilder.cpp
+++ b/llvm/lib/IR/IRBuilder.cpp
@@ -524,8 +524,9 @@ CallInst *IRBuilderBase::CreateMaskedLoad(Value *Ptr, Align Alignment,
CallInst *IRBuilderBase::CreateMaskedStore(Value *Val, Value *Ptr,
Align Alignment, Value *Mask) {
auto *PtrTy = cast<PointerType>(Ptr->getType());
- Type *DataTy = PtrTy->getElementType();
- assert(DataTy->isVectorTy() && "Ptr should point to a vector");
+ Type *DataTy = Val->getType();
+ assert(DataTy->isVectorTy() && "Val should be a vector");
+ assert(PtrTy->isOpaqueOrPointeeTypeMatches(DataTy) && "Wrong element type");
assert(Mask && "Mask should not be all-ones (null)");
Type *OverloadedTypes[] = { DataTy, PtrTy };
Value *Ops[] = {Val, Ptr, getInt32(Alignment.value()), Mask};
@@ -590,9 +591,9 @@ CallInst *IRBuilderBase::CreateMaskedScatter(Value *Data, Value *Ptrs,
ElementCount NumElts = PtrsTy->getElementCount();
#ifndef NDEBUG
- auto PtrTy = cast<PointerType>(PtrsTy->getElementType());
+ auto *PtrTy = cast<PointerType>(PtrsTy->getElementType());
assert(NumElts == DataTy->getElementCount() &&
- PtrTy->getElementType() == DataTy->getElementType() &&
+ PtrTy->isOpaqueOrPointeeTypeMatches(DataTy->getElementType()) &&
"Incompatible pointer and data types");
#endif
More information about the llvm-commits
mailing list