diff options
Diffstat (limited to 'llvm/lib/IR/ConstantFold.cpp')
-rw-r--r-- | llvm/lib/IR/ConstantFold.cpp | 22 |
1 files changed, 3 insertions, 19 deletions
diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp index 7e73be124c3..39cb156c802 100644 --- a/llvm/lib/IR/ConstantFold.cpp +++ b/llvm/lib/IR/ConstantFold.cpp @@ -2041,7 +2041,7 @@ static Constant *ConstantFoldGetElementPtrImpl(Type *PointeeTy, Constant *C, if (isa<UndefValue>(C)) { PointerType *PtrTy = cast<PointerType>(C->getType()->getScalarType()); - Type *Ty = GetElementPtrInst::getIndexedType(PtrTy->getElementType(), Idxs); + Type *Ty = GetElementPtrInst::getIndexedType(PointeeTy, Idxs); assert(Ty && "Invalid indices for GEP!"); Type *GEPTy = PointerType::get(Ty, PtrTy->getAddressSpace()); if (VectorType *VT = dyn_cast<VectorType>(C->getType())) @@ -2058,8 +2058,8 @@ static Constant *ConstantFoldGetElementPtrImpl(Type *PointeeTy, Constant *C, } if (isNull) { PointerType *PtrTy = cast<PointerType>(C->getType()->getScalarType()); - Type *Ty = - GetElementPtrInst::getIndexedType(PtrTy->getElementType(), Idxs); + Type *Ty = GetElementPtrInst::getIndexedType(PointeeTy, Idxs); + assert(Ty && "Invalid indices for GEP!"); Type *GEPTy = PointerType::get(Ty, PtrTy->getAddressSpace()); if (VectorType *VT = dyn_cast<VectorType>(C->getType())) @@ -2241,22 +2241,6 @@ static Constant *ConstantFoldGetElementPtrImpl(Type *PointeeTy, Constant *C, return nullptr; } -Constant *llvm::ConstantFoldGetElementPtr(Constant *C, - bool inBounds, - ArrayRef<Constant *> Idxs) { - return ConstantFoldGetElementPtrImpl( - cast<PointerType>(C->getType()->getScalarType())->getElementType(), C, - inBounds, Idxs); -} - -Constant *llvm::ConstantFoldGetElementPtr(Constant *C, - bool inBounds, - ArrayRef<Value *> Idxs) { - return ConstantFoldGetElementPtrImpl( - cast<PointerType>(C->getType()->getScalarType())->getElementType(), C, - inBounds, Idxs); -} - Constant *llvm::ConstantFoldGetElementPtr(Type *Ty, Constant *C, bool inBounds, ArrayRef<Constant *> Idxs) { |