Make ConstantVector::get() always take an ArrayRef, never a std::vector.
authorJay Foad <jay.foad@gmail.com>
Wed, 22 Jun 2011 09:10:19 +0000 (09:10 +0000)
committerJay Foad <jay.foad@gmail.com>
Wed, 22 Jun 2011 09:10:19 +0000 (09:10 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133614 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Constants.h
lib/VMCore/ConstantFold.cpp
lib/VMCore/Constants.cpp

index 268f920ad7997a2627f485c87f624e9060902356..aa3096022b913d4ecd454b490cf65ad643f4314e 100644 (file)
@@ -491,8 +491,6 @@ protected:
 public:
   // ConstantVector accessors
   static Constant *get(ArrayRef<Constant*> V);
-  // FIXME: Eliminate this constructor form.
-  static Constant *get(const VectorType *T, const std::vector<Constant*> &V);
   
   /// Transparently provide more efficient getOperand methods.
   DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant);
index e5ab15dbe16a65964641d7820756163763413fc2..579d356b1de292f113dc24aa8d6d14ae6195c033 100644 (file)
@@ -559,7 +559,7 @@ Constant *llvm::ConstantFoldCastInstruction(unsigned opc, Constant *V,
       for (unsigned i = 0, e = CV->getType()->getNumElements(); i != e; ++i)
         res.push_back(ConstantExpr::getCast(opc,
                                             CV->getOperand(i), DstEltTy));
-      return ConstantVector::get(DestVecTy, res);
+      return ConstantVector::get(res);
     }
 
   // We actually have to do a cast now. Perform the cast according to the
index 4c03288fe44073cdd78e7d85a14ef965a77ce3c0..2fee173a1f747451a37362a6137c9064e4beb63f 100644 (file)
@@ -698,9 +698,9 @@ ConstantVector::ConstantVector(const VectorType *T,
 }
 
 // ConstantVector accessors.
-Constant *ConstantVector::get(const VectorType *T,
-                              const std::vector<Constant*> &V) {
+Constant *ConstantVector::get(ArrayRef<Constant*> V) {
   assert(!V.empty() && "Vectors can't be empty");
+  const VectorType *T = VectorType::get(V.front()->getType(), V.size());
   LLVMContextImpl *pImpl = T->getContext().pImpl;
 
   // If this is an all-undef or all-zero vector, return a
@@ -725,12 +725,6 @@ Constant *ConstantVector::get(const VectorType *T,
   return pImpl->VectorConstants.getOrCreate(T, V);
 }
 
-Constant *ConstantVector::get(ArrayRef<Constant*> V) {
-  // FIXME: make this the primary ctor method.
-  assert(!V.empty() && "Vectors cannot be empty");
-  return get(VectorType::get(V.front()->getType(), V.size()), V.vec());
-}
-
 // Utility function for determining if a ConstantExpr is a CastOp or not. This
 // can't be inline because we don't want to #include Instruction.h into
 // Constant.h
@@ -2118,7 +2112,7 @@ void ConstantVector::replaceUsesOfWithOnConstant(Value *From, Value *To,
     Values.push_back(Val);
   }
   
-  Constant *Replacement = get(cast<VectorType>(getRawType()), Values);
+  Constant *Replacement = get(Values);
   assert(Replacement != this && "I didn't contain From!");
   
   // Everyone using this now uses the replacement.