[llvm] r258474 - [opaque pointer types] [NFC] gep_type_{begin, end} now take source element type and address space.

Eduard Burtescu via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 21 17:33:43 PST 2016


Author: eddyb
Date: Thu Jan 21 19:33:43 2016
New Revision: 258474

URL: http://llvm.org/viewvc/llvm-project?rev=258474&view=rev
Log:
[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

Modified:
    llvm/trunk/include/llvm/Analysis/TargetTransformInfoImpl.h
    llvm/trunk/include/llvm/IR/GetElementPtrTypeIterator.h
    llvm/trunk/lib/IR/DataLayout.cpp

Modified: llvm/trunk/include/llvm/Analysis/TargetTransformInfoImpl.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/TargetTransformInfoImpl.h?rev=258474&r1=258473&r2=258474&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/TargetTransformInfoImpl.h (original)
+++ llvm/trunk/include/llvm/Analysis/TargetTransformInfoImpl.h Thu Jan 21 19:33:43 2016
@@ -423,7 +423,7 @@ public:
     // Assumes the address space is 0 when Ptr is nullptr.
     unsigned AS =
         (Ptr == nullptr ? 0 : Ptr->getType()->getPointerAddressSpace());
-    auto GTI = gep_type_begin(PointerType::get(PointeeType, AS), Operands);
+    auto GTI = gep_type_begin(PointeeType, AS, Operands);
     for (auto I = Operands.begin(); I != Operands.end(); ++I, ++GTI) {
       // We assume that the cost of Scalar GEP with constant index and the
       // cost of Vector GEP with splat constant index are the same.

Modified: llvm/trunk/include/llvm/IR/GetElementPtrTypeIterator.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/GetElementPtrTypeIterator.h?rev=258474&r1=258473&r2=258474&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/GetElementPtrTypeIterator.h (original)
+++ llvm/trunk/include/llvm/IR/GetElementPtrTypeIterator.h Thu Jan 21 19:33:43 2016
@@ -33,12 +33,6 @@ namespace llvm {
     generic_gep_type_iterator() {}
   public:
 
-    static generic_gep_type_iterator begin(Type *Ty, ItTy It) {
-      generic_gep_type_iterator I;
-      I.CurTy.setPointer(Ty);
-      I.OpIt = It;
-      return I;
-    }
     static generic_gep_type_iterator begin(Type *Ty, unsigned AddrSpace,
                                            ItTy It) {
       generic_gep_type_iterator I;
@@ -125,13 +119,13 @@ namespace llvm {
 
   template<typename T>
   inline generic_gep_type_iterator<const T *>
-  gep_type_begin(Type *Op0, ArrayRef<T> A) {
-    return generic_gep_type_iterator<const T *>::begin(Op0, A.begin());
+  gep_type_begin(Type *Op0, unsigned AS, ArrayRef<T> A) {
+    return generic_gep_type_iterator<const T *>::begin(Op0, AS, A.begin());
   }
 
   template<typename T>
   inline generic_gep_type_iterator<const T *>
-  gep_type_end(Type * /*Op0*/, ArrayRef<T> A) {
+  gep_type_end(Type * /*Op0*/, unsigned /*AS*/, ArrayRef<T> A) {
     return generic_gep_type_iterator<const T *>::end(A.end());
   }
 } // end namespace llvm

Modified: llvm/trunk/lib/IR/DataLayout.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DataLayout.cpp?rev=258474&r1=258473&r2=258474&view=diff
==============================================================================
--- llvm/trunk/lib/IR/DataLayout.cpp (original)
+++ llvm/trunk/lib/IR/DataLayout.cpp Thu Jan 21 19:33:43 2016
@@ -729,8 +729,11 @@ uint64_t DataLayout::getIndexedOffset(Ty
   assert(Ty->isPointerTy() && "Illegal argument for getIndexedOffset()");
   uint64_t Result = 0;
 
+  // We can use 0 as the address space as we don't need
+  // to get pointer types back from gep_type_iterator.
+  unsigned AS = 0;
   generic_gep_type_iterator<Value* const*>
-    TI = gep_type_begin(ptrTy, Indices);
+    TI = gep_type_begin(ptrTy->getPointerElementType(), AS, Indices);
   for (unsigned CurIDX = 0, EndIDX = Indices.size(); CurIDX != EndIDX;
        ++CurIDX, ++TI) {
     if (StructType *STy = dyn_cast<StructType>(*TI)) {




More information about the llvm-commits mailing list