[opaque pointer type] Access the pointee of the result type from the GEP rather than...
authorDavid Blaikie <dblaikie@gmail.com>
Fri, 17 Apr 2015 22:32:20 +0000 (22:32 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Fri, 17 Apr 2015 22:32:20 +0000 (22:32 +0000)
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
lib/IR/Verifier.cpp

index ff9254372ead2f25c1644d2b06abfbb5196aecee..2571faf3836277eec3a003291af60f58369f18d4 100644 (file)
@@ -876,7 +876,9 @@ public:
         ->getElementType();
   }
 
         ->getElementType();
   }
 
-  Type *getResultElementType() const { return getType()->getElementType(); }
+  Type *getResultElementType() const {
+    return cast<PointerType>(getType()->getScalarType())->getElementType();
+  }
 
   /// \brief Returns the address space of this instruction's pointer type.
   unsigned getAddressSpace() const {
 
   /// \brief Returns the address space of this instruction's pointer type.
   unsigned getAddressSpace() const {
index bd9f3f3c3ea057860595442db108cc156bb29ae7..e14f1036912eec6717cfcff6ff67f502c47d20dd 100644 (file)
@@ -2462,8 +2462,7 @@ void Verifier::visitGetElementPtrInst(GetElementPtrInst &GEP) {
   Assert(ElTy, "Invalid indices for GEP pointer type!", &GEP);
 
   Assert(GEP.getType()->getScalarType()->isPointerTy() &&
   Assert(ElTy, "Invalid indices for GEP pointer type!", &GEP);
 
   Assert(GEP.getType()->getScalarType()->isPointerTy() &&
-             cast<PointerType>(GEP.getType()->getScalarType())
-                     ->getElementType() == ElTy,
+             GEP.getResultElementType() == ElTy,
          "GEP is not of right type for indices!", &GEP, ElTy);
 
   if (GEP.getPointerOperandType()->isVectorTy()) {
          "GEP is not of right type for indices!", &GEP, ElTy);
 
   if (GEP.getPointerOperandType()->isVectorTy()) {