diff options
| author | Igor Laevsky <igmyrj@gmail.com> | 2017-12-14 09:33:58 +0000 |
|---|---|---|
| committer | Igor Laevsky <igmyrj@gmail.com> | 2017-12-14 09:33:58 +0000 |
| commit | 753395fa0abe3b612e4b6e36c78b516ddad2b2a7 (patch) | |
| tree | f9f4611b7a5d53c94cc0dd5508bdc2e0db466117 /llvm/lib | |
| parent | ef12b41ef76eb842c64251fc7ee06ad5d6b850c2 (diff) | |
| download | bcm5719-llvm-753395fa0abe3b612e4b6e36c78b516ddad2b2a7.tar.gz bcm5719-llvm-753395fa0abe3b612e4b6e36c78b516ddad2b2a7.zip | |
[Verifier] Check that GEP indexes has correct types
Differential Revision: https://reviews.llvm.org/D40391
llvm-svn: 320680
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/IR/Verifier.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 6137faf38a9..f6faf1309d8 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -3016,7 +3016,11 @@ void Verifier::visitGetElementPtrInst(GetElementPtrInst &GEP) { Assert(isa<PointerType>(TargetTy), "GEP base pointer is not a vector or a vector of pointers", &GEP); Assert(GEP.getSourceElementType()->isSized(), "GEP into unsized type!", &GEP); + SmallVector<Value*, 16> Idxs(GEP.idx_begin(), GEP.idx_end()); + Assert(all_of( + Idxs, [](Value* V) { return V->getType()->isIntOrIntVectorTy(); }), + "GEP indexes must be integers", &GEP); Type *ElTy = GetElementPtrInst::getIndexedType(GEP.getSourceElementType(), Idxs); Assert(ElTy, "Invalid indices for GEP pointer type!", &GEP); |

