From 4ba5d91a08249edc55c521f1c94ced9062e6cb58 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Fri, 17 Apr 2015 22:32:20 +0000 Subject: [PATCH] [opaque pointer type] Access the pointee of the result type from the GEP rather than pulling it out of the pointer result type The implementation of this GEP::getResultElementType will be refactored to either rely on a member variable, or recompute the value from the indicies (any preferences?). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235236 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/Instructions.h | 4 +++- lib/IR/Verifier.cpp | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) 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()) { -- 2.34.1