[llvm] r235234 - [opaque pointer type] Avoid creating (and then unwrapping) a pointer type to compute the result type of a GEP
David Blaikie
dblaikie at gmail.com
Fri Apr 17 15:32:16 PDT 2015
Author: dblaikie
Date: Fri Apr 17 17:32:16 2015
New Revision: 235234
URL: http://llvm.org/viewvc/llvm-project?rev=235234&view=rev
Log:
[opaque pointer type] Avoid creating (and then unwrapping) a pointer type to compute the result type of a GEP
Modified:
llvm/trunk/include/llvm/IR/Instructions.h
Modified: llvm/trunk/include/llvm/IR/Instructions.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Instructions.h?rev=235234&r1=235233&r2=235234&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Instructions.h (original)
+++ llvm/trunk/include/llvm/IR/Instructions.h Fri Apr 17 17:32:16 2015
@@ -924,12 +924,14 @@ public:
/// GetGEPReturnType - Returns the pointer type returned by the GEP
/// instruction, which may be a vector of pointers.
static Type *getGEPReturnType(Value *Ptr, ArrayRef<Value *> IdxList) {
- Type *PtrTy =
- PointerType::get(checkGEPType(getIndexedType(
- cast<PointerType>(Ptr->getType()->getScalarType())
- ->getElementType(),
- IdxList)),
- Ptr->getType()->getPointerAddressSpace());
+ return getGEPReturnType(
+ cast<PointerType>(Ptr->getType()->getScalarType())->getElementType(),
+ Ptr, IdxList);
+ }
+ static Type *getGEPReturnType(Type *ElTy, Value *Ptr,
+ ArrayRef<Value *> IdxList) {
+ Type *PtrTy = PointerType::get(checkGEPType(getIndexedType(ElTy, IdxList)),
+ Ptr->getType()->getPointerAddressSpace());
// Vector GEP
if (Ptr->getType()->isVectorTy()) {
unsigned NumElem = cast<VectorType>(Ptr->getType())->getNumElements();
@@ -993,7 +995,9 @@ GetElementPtrInst::GetElementPtrInst(Typ
ArrayRef<Value *> IdxList, unsigned Values,
const Twine &NameStr,
Instruction *InsertBefore)
- : Instruction(getGEPReturnType(Ptr, IdxList), GetElementPtr,
+ : Instruction(PointeeType ? getGEPReturnType(PointeeType, Ptr, IdxList)
+ : getGEPReturnType(Ptr, IdxList),
+ GetElementPtr,
OperandTraits<GetElementPtrInst>::op_end(this) - Values,
Values, InsertBefore) {
init(Ptr, IdxList, NameStr);
More information about the llvm-commits
mailing list