From 7ef9c9ad1e0f52ec1e8b1fcb26d410165eb5a896 Mon Sep 17 00:00:00 2001 From: Jay Foad Date: Wed, 22 Jun 2011 09:10:19 +0000 Subject: [PATCH] Make ConstantVector::get() always take an ArrayRef, never a std::vector. llvm-svn: 133614 --- include/llvm/Constants.h | 2 -- lib/VMCore/ConstantFold.cpp | 2 +- lib/VMCore/Constants.cpp | 12 +++--------- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h index 268f920ad79..aa3096022b9 100644 --- a/include/llvm/Constants.h +++ b/include/llvm/Constants.h @@ -491,8 +491,6 @@ protected: public: // ConstantVector accessors static Constant *get(ArrayRef V); - // FIXME: Eliminate this constructor form. - static Constant *get(const VectorType *T, const std::vector &V); /// Transparently provide more efficient getOperand methods. DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant); diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp index e5ab15dbe16..579d356b1de 100644 --- a/lib/VMCore/ConstantFold.cpp +++ b/lib/VMCore/ConstantFold.cpp @@ -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 diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp index 4c03288fe44..2fee173a1f7 100644 --- a/lib/VMCore/Constants.cpp +++ b/lib/VMCore/Constants.cpp @@ -698,9 +698,9 @@ ConstantVector::ConstantVector(const VectorType *T, } // ConstantVector accessors. -Constant *ConstantVector::get(const VectorType *T, - const std::vector &V) { +Constant *ConstantVector::get(ArrayRef 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 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(getRawType()), Values); + Constant *Replacement = get(Values); assert(Replacement != this && "I didn't contain From!"); // Everyone using this now uses the replacement.