[opaque pointer type] more gep API migration
authorDavid Blaikie <dblaikie@gmail.com>
Sat, 14 Mar 2015 19:53:33 +0000 (19:53 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Sat, 14 Mar 2015 19:53:33 +0000 (19:53 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232274 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/PHITransAddr.cpp
lib/Bitcode/Reader/BitcodeReader.cpp
lib/Target/NVPTX/NVPTXFavorNonGenericAddrSpaces.cpp
lib/Transforms/IPO/ArgumentPromotion.cpp
lib/Transforms/InstCombine/InstructionCombining.cpp

index a534418d199ee61243ecb1f127d85c20fdd2ee02..177684fdc9a757d0295bf056b33271af0821857c 100644 (file)
@@ -404,10 +404,9 @@ InsertPHITranslatedSubExpr(Value *InVal, BasicBlock *CurBB,
       GEPOps.push_back(OpVal);
     }
 
-    GetElementPtrInst *Result =
-      GetElementPtrInst::Create(GEPOps[0], makeArrayRef(GEPOps).slice(1),
-                                InVal->getName()+".phi.trans.insert",
-                                PredBB->getTerminator());
+    GetElementPtrInst *Result = GetElementPtrInst::Create(
+        GEP->getSourceElementType(), GEPOps[0], makeArrayRef(GEPOps).slice(1),
+        InVal->getName() + ".phi.trans.insert", PredBB->getTerminator());
     Result->setIsInBounds(GEP->isInBounds());
     NewInsts.push_back(Result);
     return Result;
index 9a0ec19e6f36326ce50302dc2c7dca35be14162d..143bb3dad9ed3fcd10a1aa827f3af5ee8b6547c0 100644 (file)
@@ -3131,7 +3131,7 @@ std::error_code BitcodeReader::ParseFunctionBody(Function *F) {
         GEPIdx.push_back(Op);
       }
 
-      I = GetElementPtrInst::Create(BasePtr, GEPIdx);
+      I = GetElementPtrInst::Create(Ty, BasePtr, GEPIdx);
       if (Ty && Ty != cast<GetElementPtrInst>(I)->getSourceElementType())
         return Error("Invalid record");
       InstructionList.push_back(I);
index f3a095d829e409ad026c1e0f91f79df9d6efff50..6d7c99c6f3ff7861513276ff6e513ffe94dcda61 100644 (file)
@@ -123,10 +123,9 @@ bool NVPTXFavorNonGenericAddrSpaces::hoistAddrSpaceCastFromGEP(
     // =>
     // %0 = gep X, indices
     // %1 = addrspacecast %0
-    GetElementPtrInst *NewGEPI = GetElementPtrInst::Create(Cast->getOperand(0),
-                                                           Indices,
-                                                           GEP->getName(),
-                                                           GEPI);
+    GetElementPtrInst *NewGEPI = GetElementPtrInst::Create(
+        GEP->getSourceElementType(), Cast->getOperand(0), Indices,
+        GEP->getName(), GEPI);
     NewGEPI->setIsInBounds(GEP->isInBounds());
     GEP->replaceAllUsesWith(
         new AddrSpaceCastInst(NewGEPI, GEP->getType(), "", GEPI));
index a0687738b165950e0c0a4b1e7ecae8926d6c2f8a..1f4d6c1254d71025fb57f2e59b511f92ce3af733 100644 (file)
@@ -900,10 +900,9 @@ CallGraphNode *ArgPromotion::DoPromotion(Function *F,
 
       for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
         Idxs[1] = ConstantInt::get(Type::getInt32Ty(F->getContext()), i);
-        Value *Idx = 
-          GetElementPtrInst::Create(TheAlloca, Idxs,
-                                    TheAlloca->getName()+"."+Twine(i), 
-                                    InsertPt);
+        Value *Idx = GetElementPtrInst::Create(
+            AgTy, TheAlloca, Idxs, TheAlloca->getName() + "." + Twine(i),
+            InsertPt);
         I2->setName(I->getName()+"."+Twine(i));
         new StoreInst(I2++, Idx, InsertPt);
       }
index 434d129bf396b2c5b938b283999a7717fca1b878..96d9adc718ba77ae203c8ef9ad40a311913f8767 100644 (file)
@@ -1476,10 +1476,13 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) {
     }
 
     if (!Indices.empty())
-      return (GEP.isInBounds() && Src->isInBounds()) ?
-        GetElementPtrInst::CreateInBounds(Src->getOperand(0), Indices,
-                                          GEP.getName()) :
-        GetElementPtrInst::Create(Src->getOperand(0), Indices, GEP.getName());
+      return GEP.isInBounds() && Src->isInBounds()
+                 ? GetElementPtrInst::CreateInBounds(
+                       Src->getSourceElementType(), Src->getOperand(0), Indices,
+                       GEP.getName())
+                 : GetElementPtrInst::Create(Src->getSourceElementType(),
+                                             Src->getOperand(0), Indices,
+                                             GEP.getName());
   }
 
   if (GEP.getNumIndices() == 1) {
@@ -1557,8 +1560,8 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) {
         if (CATy->getElementType() == StrippedPtrTy->getElementType()) {
           // -> GEP i8* X, ...
           SmallVector<Value*, 8> Idx(GEP.idx_begin()+1, GEP.idx_end());
-          GetElementPtrInst *Res =
-            GetElementPtrInst::Create(StrippedPtr, Idx, GEP.getName());
+          GetElementPtrInst *Res = GetElementPtrInst::Create(
+              StrippedPtrTy->getElementType(), StrippedPtr, Idx, GEP.getName());
           Res->setIsInBounds(GEP.isInBounds());
           if (StrippedPtrTy->getAddressSpace() == GEP.getAddressSpace())
             return Res;