[llvm] r235236 - [opaque pointer type] Access the pointee of the result type from the GEP rather than pulling it out of the pointer result type
David Blaikie
dblaikie at gmail.com
Fri Apr 17 15:32:21 PDT 2015
Author: dblaikie
Date: Fri Apr 17 17:32:20 2015
New Revision: 235236
URL: http://llvm.org/viewvc/llvm-project?rev=235236&view=rev
Log:
[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?).
Modified:
llvm/trunk/include/llvm/IR/Instructions.h
llvm/trunk/lib/IR/Verifier.cpp
Modified: llvm/trunk/include/llvm/IR/Instructions.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Instructions.h?rev=235236&r1=235235&r2=235236&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Instructions.h (original)
+++ llvm/trunk/include/llvm/IR/Instructions.h Fri Apr 17 17:32:20 2015
@@ -876,7 +876,9 @@ public:
->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 {
Modified: llvm/trunk/lib/IR/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Verifier.cpp?rev=235236&r1=235235&r2=235236&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Verifier.cpp (original)
+++ llvm/trunk/lib/IR/Verifier.cpp Fri Apr 17 17:32:20 2015
@@ -2462,8 +2462,7 @@ void Verifier::visitGetElementPtrInst(Ge
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()) {
More information about the llvm-commits
mailing list