diff --git a/include/llvm/IR/Instructions.h b/include/llvm/IR/Instructions.h index ff9254372ea..2571faf3836 100644 --- a/include/llvm/IR/Instructions.h +++ b/include/llvm/IR/Instructions.h @@ -876,7 +876,9 @@ public: ->getElementType(); } - Type *getResultElementType() const { return getType()->getElementType(); } + Type *getResultElementType() const { + return cast(getType()->getScalarType())->getElementType(); + } /// \brief Returns the address space of this instruction's pointer type. unsigned getAddressSpace() const { diff --git a/lib/IR/Verifier.cpp b/lib/IR/Verifier.cpp index bd9f3f3c3ea..e14f1036912 100644 --- a/lib/IR/Verifier.cpp +++ b/lib/IR/Verifier.cpp @@ -2462,8 +2462,7 @@ void Verifier::visitGetElementPtrInst(GetElementPtrInst &GEP) { Assert(ElTy, "Invalid indices for GEP pointer type!", &GEP); Assert(GEP.getType()->getScalarType()->isPointerTy() && - cast(GEP.getType()->getScalarType()) - ->getElementType() == ElTy, + GEP.getResultElementType() == ElTy, "GEP is not of right type for indices!", &GEP, ElTy); if (GEP.getPointerOperandType()->isVectorTy()) {