[opaque pointer type] gep API migration
authorDavid Blaikie <dblaikie@gmail.com>
Sat, 14 Mar 2015 21:40:10 +0000 (21:40 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Sat, 14 Mar 2015 21:40:10 +0000 (21:40 +0000)
This concludes the GetElementPtrInst::Create migration, thus marking the
beginning of the IRBuilder::CreateGEP* migration to come.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232280 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/IR/Instructions.h
unittests/IR/InstructionsTest.cpp
unittests/Transforms/Utils/Cloning.cpp

index 2e84d95c4aac56381f8c8b195470d0de9d7f01df..52fa3607ad531e94dd44c3c36158a3f62be5d5dd 100644 (file)
@@ -804,11 +804,6 @@ class GetElementPtrInst : public Instruction {
 protected:
   GetElementPtrInst *clone_impl() const override;
 public:
-  static GetElementPtrInst *Create(Value *Ptr, ArrayRef<Value *> IdxList,
-                                   const Twine &NameStr = "",
-                                   Instruction *InsertBefore = nullptr) {
-    return Create(nullptr, Ptr, IdxList, NameStr, InsertBefore);
-  }
   static GetElementPtrInst *Create(Type *PointeeType, Value *Ptr,
                                    ArrayRef<Value *> IdxList,
                                    const Twine &NameStr = "",
@@ -817,11 +812,6 @@ public:
     return new (Values) GetElementPtrInst(PointeeType, Ptr, IdxList, Values,
                                           NameStr, InsertBefore);
   }
-  static GetElementPtrInst *Create(Value *Ptr, ArrayRef<Value *> IdxList,
-                                   const Twine &NameStr,
-                                   BasicBlock *InsertAtEnd) {
-    return Create(nullptr, Ptr, NameStr, InsertAtEnd);
-  }
   static GetElementPtrInst *Create(Type *PointeeType, Value *Ptr,
                                    ArrayRef<Value *> IdxList,
                                    const Twine &NameStr,
index 3eb3e491a10ba9c6d2c1299422f108cae6fffc98..3ca3ad2b6e8376c99828c66137f283a15bd7a290 100644 (file)
@@ -291,8 +291,10 @@ TEST(InstructionsTest, VectorGep) {
   LLVMContext &C(getGlobalContext());
 
   // Type Definitions
-  PointerType *Ptri8Ty = PointerType::get(IntegerType::get(C, 8), 0);
-  PointerType *Ptri32Ty = PointerType::get(IntegerType::get(C, 32), 0);
+  Type *I8Ty = IntegerType::get(C, 8);
+  Type *I32Ty = IntegerType::get(C, 32);
+  PointerType *Ptri8Ty = PointerType::get(I8Ty, 0);
+  PointerType *Ptri32Ty = PointerType::get(I32Ty, 0);
 
   VectorType *V2xi8PTy = VectorType::get(Ptri8Ty, 2);
   VectorType *V2xi32PTy = VectorType::get(Ptri32Ty, 2);
@@ -318,10 +320,10 @@ TEST(InstructionsTest, VectorGep) {
   ICmpInst *ICmp2 = new ICmpInst(*BB0, ICmpInst::ICMP_SGE, PtrVecA, PtrVecB);
   EXPECT_NE(ICmp0, ICmp2); // suppress warning.
 
-  GetElementPtrInst *Gep0 = GetElementPtrInst::Create(PtrVecA, C2xi32a);
-  GetElementPtrInst *Gep1 = GetElementPtrInst::Create(PtrVecA, C2xi32b);
-  GetElementPtrInst *Gep2 = GetElementPtrInst::Create(PtrVecB, C2xi32a);
-  GetElementPtrInst *Gep3 = GetElementPtrInst::Create(PtrVecB, C2xi32b);
+  GetElementPtrInst *Gep0 = GetElementPtrInst::Create(I32Ty, PtrVecA, C2xi32a);
+  GetElementPtrInst *Gep1 = GetElementPtrInst::Create(I32Ty, PtrVecA, C2xi32b);
+  GetElementPtrInst *Gep2 = GetElementPtrInst::Create(I32Ty, PtrVecB, C2xi32a);
+  GetElementPtrInst *Gep3 = GetElementPtrInst::Create(I32Ty, PtrVecB, C2xi32b);
 
   CastInst *BTC0 = new BitCastInst(Gep0, V2xi8PTy);
   CastInst *BTC1 = new BitCastInst(Gep1, V2xi8PTy);
@@ -349,10 +351,10 @@ TEST(InstructionsTest, VectorGep) {
   GetPointerBaseWithConstantOffset(Gep3, Offset, TD);
 
   // Gep of Geps
-  GetElementPtrInst *GepII0 = GetElementPtrInst::Create(Gep0, C2xi32b);
-  GetElementPtrInst *GepII1 = GetElementPtrInst::Create(Gep1, C2xi32a);
-  GetElementPtrInst *GepII2 = GetElementPtrInst::Create(Gep2, C2xi32b);
-  GetElementPtrInst *GepII3 = GetElementPtrInst::Create(Gep3, C2xi32a);
+  GetElementPtrInst *GepII0 = GetElementPtrInst::Create(I32Ty, Gep0, C2xi32b);
+  GetElementPtrInst *GepII1 = GetElementPtrInst::Create(I32Ty, Gep1, C2xi32a);
+  GetElementPtrInst *GepII2 = GetElementPtrInst::Create(I32Ty, Gep2, C2xi32b);
+  GetElementPtrInst *GepII3 = GetElementPtrInst::Create(I32Ty, Gep3, C2xi32a);
 
   EXPECT_EQ(GepII0->getNumIndices(), 1u);
   EXPECT_EQ(GepII1->getNumIndices(), 1u);
index 1d22d5b15c9ba6125f6a7ab1d903d00e4f36c0ee..8374099680e6f4994aa83a106940be8692afff21 100644 (file)
@@ -135,7 +135,8 @@ TEST_F(CloneInstruction, Inbounds) {
   Constant *Z = Constant::getNullValue(Type::getInt32Ty(context));
   std::vector<Value *> ops;
   ops.push_back(Z);
-  GetElementPtrInst *GEP = GetElementPtrInst::Create(V, ops);
+  GetElementPtrInst *GEP =
+      GetElementPtrInst::Create(Type::getInt32Ty(context), V, ops);
   EXPECT_FALSE(this->clone(GEP)->isInBounds());
 
   GEP->setIsInBounds();