Skip to content

Commit 093ae49

Browse files
committedJan 22, 2016
[opaque pointer types] [NFC] gep_type_{begin,end} now take source element type and address space.
Reviewers: mjacob, dblaikie Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D16436 llvm-svn: 258474
1 parent b008fd4 commit 093ae49

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed
 

‎llvm/include/llvm/Analysis/TargetTransformInfoImpl.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ class TargetTransformInfoImplCRTPBase : public TargetTransformInfoImplBase {
423423
// Assumes the address space is 0 when Ptr is nullptr.
424424
unsigned AS =
425425
(Ptr == nullptr ? 0 : Ptr->getType()->getPointerAddressSpace());
426-
auto GTI = gep_type_begin(PointerType::get(PointeeType, AS), Operands);
426+
auto GTI = gep_type_begin(PointeeType, AS, Operands);
427427
for (auto I = Operands.begin(); I != Operands.end(); ++I, ++GTI) {
428428
// We assume that the cost of Scalar GEP with constant index and the
429429
// cost of Vector GEP with splat constant index are the same.

‎llvm/include/llvm/IR/GetElementPtrTypeIterator.h

+3-9
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,6 @@ namespace llvm {
3333
generic_gep_type_iterator() {}
3434
public:
3535

36-
static generic_gep_type_iterator begin(Type *Ty, ItTy It) {
37-
generic_gep_type_iterator I;
38-
I.CurTy.setPointer(Ty);
39-
I.OpIt = It;
40-
return I;
41-
}
4236
static generic_gep_type_iterator begin(Type *Ty, unsigned AddrSpace,
4337
ItTy It) {
4438
generic_gep_type_iterator I;
@@ -125,13 +119,13 @@ namespace llvm {
125119

126120
template<typename T>
127121
inline generic_gep_type_iterator<const T *>
128-
gep_type_begin(Type *Op0, ArrayRef<T> A) {
129-
return generic_gep_type_iterator<const T *>::begin(Op0, A.begin());
122+
gep_type_begin(Type *Op0, unsigned AS, ArrayRef<T> A) {
123+
return generic_gep_type_iterator<const T *>::begin(Op0, AS, A.begin());
130124
}
131125

132126
template<typename T>
133127
inline generic_gep_type_iterator<const T *>
134-
gep_type_end(Type * /*Op0*/, ArrayRef<T> A) {
128+
gep_type_end(Type * /*Op0*/, unsigned /*AS*/, ArrayRef<T> A) {
135129
return generic_gep_type_iterator<const T *>::end(A.end());
136130
}
137131
} // end namespace llvm

‎llvm/lib/IR/DataLayout.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -729,8 +729,11 @@ uint64_t DataLayout::getIndexedOffset(Type *ptrTy,
729729
assert(Ty->isPointerTy() && "Illegal argument for getIndexedOffset()");
730730
uint64_t Result = 0;
731731

732+
// We can use 0 as the address space as we don't need
733+
// to get pointer types back from gep_type_iterator.
734+
unsigned AS = 0;
732735
generic_gep_type_iterator<Value* const*>
733-
TI = gep_type_begin(ptrTy, Indices);
736+
TI = gep_type_begin(ptrTy->getPointerElementType(), AS, Indices);
734737
for (unsigned CurIDX = 0, EndIDX = Indices.size(); CurIDX != EndIDX;
735738
++CurIDX, ++TI) {
736739
if (StructType *STy = dyn_cast<StructType>(*TI)) {

0 commit comments

Comments
 (0)