aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/Verifier.cpp
diff options
context:
space:
mode:
authorMatt Arsenault <Matthew.Arsenault@amd.com>2024-10-29 19:41:49 -0700
committerGitHub <noreply@github.com>2024-10-29 19:41:49 -0700
commit9e8219a78c80442fb0f795f17926595a94a8e7d7 (patch)
treed5f76d63389869c2db6b344e79540d7cf2cd13ce /llvm/lib/IR/Verifier.cpp
parentfacdae62b7be4fe177c8a130c68aef0305dc6eb3 (diff)
downloadllvm-9e8219a78c80442fb0f795f17926595a94a8e7d7.zip
llvm-9e8219a78c80442fb0f795f17926595a94a8e7d7.tar.gz
llvm-9e8219a78c80442fb0f795f17926595a94a8e7d7.tar.bz2
IR: Fix verifier missing addrspace mismatch in vector GEPs (#114091)
Diffstat (limited to 'llvm/lib/IR/Verifier.cpp')
-rw-r--r--llvm/lib/IR/Verifier.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index ee807ca..ffcab98 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -4121,8 +4121,9 @@ void Verifier::visitGetElementPtrInst(GetElementPtrInst &GEP) {
GetElementPtrInst::getIndexedType(GEP.getSourceElementType(), Idxs);
Check(ElTy, "Invalid indices for GEP pointer type!", &GEP);
- Check(GEP.getType()->isPtrOrPtrVectorTy() &&
- GEP.getResultElementType() == ElTy,
+ PointerType *PtrTy = dyn_cast<PointerType>(GEP.getType()->getScalarType());
+
+ Check(PtrTy && GEP.getResultElementType() == ElTy,
"GEP is not of right type for indices!", &GEP, ElTy);
if (auto *GEPVTy = dyn_cast<VectorType>(GEP.getType())) {
@@ -4144,10 +4145,8 @@ void Verifier::visitGetElementPtrInst(GetElementPtrInst &GEP) {
}
}
- if (auto *PTy = dyn_cast<PointerType>(GEP.getType())) {
- Check(GEP.getAddressSpace() == PTy->getAddressSpace(),
- "GEP address space doesn't match type", &GEP);
- }
+ Check(GEP.getAddressSpace() == PtrTy->getAddressSpace(),
+ "GEP address space doesn't match type", &GEP);
visitInstruction(GEP);
}