Replace the existing forms of ConstantArray::get() with a single form
authorJay Foad <jay.foad@gmail.com>
Wed, 22 Jun 2011 09:24:39 +0000 (09:24 +0000)
committerJay Foad <jay.foad@gmail.com>
Wed, 22 Jun 2011 09:24:39 +0000 (09:24 +0000)
that takes an ArrayRef.

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

include/llvm/Constants.h
lib/AsmParser/LLParser.cpp
lib/Bitcode/Reader/BitcodeReader.cpp
lib/CodeGen/SelectionDAG/DAGCombiner.cpp
lib/CodeGen/ShadowStackGC.cpp
lib/Transforms/Instrumentation/GCOVProfiling.cpp
lib/VMCore/Constants.cpp
lib/VMCore/Core.cpp

index aa3096022b913d4ecd454b490cf65ad643f4314e..ff599512e6f70d89489bb699a81242805993f633 100644 (file)
@@ -350,9 +350,7 @@ protected:
   ConstantArray(const ArrayType *T, const std::vector<Constant*> &Val);
 public:
   // ConstantArray accessors
-  static Constant *get(const ArrayType *T, const std::vector<Constant*> &V);
-  static Constant *get(const ArrayType *T, Constant *const *Vals, 
-                       unsigned NumVals);
+  static Constant *get(const ArrayType *T, ArrayRef<Constant*> V);
                              
   /// This method constructs a ConstantArray and initializes it with a text
   /// string. The default behavior (AddNull==true) causes a null terminator to
index 170ec44391fb814052ace8e4c5ffb208514f51e0..d9858514be081bd7119b3cd84d52da6eb2160a40 100644 (file)
@@ -2062,7 +2062,7 @@ bool LLParser::ParseValID(ValID &ID, PerFunctionState *PFS) {
                      " is not of type '" + getTypeString(Elts[0]->getType()));
     }
 
-    ID.ConstantVal = ConstantArray::get(ATy, Elts.data(), Elts.size());
+    ID.ConstantVal = ConstantArray::get(ATy, Elts);
     ID.Kind = ValID::t_Constant;
     return false;
   }
index ff67bc92fe19ed467e3c472bc6cccb3515bf14a1..963791f5d6c935c629ac294da5f98792f616af11 100644 (file)
@@ -292,7 +292,7 @@ void BitcodeReaderValueList::ResolveConstantForwardRefs() {
       // Make the new constant.
       Constant *NewC;
       if (ConstantArray *UserCA = dyn_cast<ConstantArray>(UserC)) {
-        NewC = ConstantArray::get(UserCA->getType(), &NewOps[0], NewOps.size());
+        NewC = ConstantArray::get(UserCA->getType(), NewOps);
       } else if (ConstantStruct *UserCS = dyn_cast<ConstantStruct>(UserC)) {
         NewC = ConstantStruct::get(UserCS->getType(), NewOps);
       } else if (isa<ConstantVector>(UserC)) {
index 443fb3271d72d0dd6f0a1d4d90ba593107344866..e3d390658485d8583ddff23959504f765f34ede6 100644 (file)
@@ -7470,7 +7470,7 @@ SDValue DAGCombiner::SimplifySelectCC(DebugLoc DL, SDValue N0, SDValue N1,
         const TargetData &TD = *TLI.getTargetData();
 
         // Create a ConstantArray of the two constants.
-        Constant *CA = ConstantArray::get(ArrayType::get(FPTy, 2), Elts, 2);
+        Constant *CA = ConstantArray::get(ArrayType::get(FPTy, 2), Elts);
         SDValue CPIdx = DAG.getConstantPool(CA, TLI.getPointerTy(),
                                             TD.getPrefTypeAlignment(FPTy));
         unsigned Alignment = cast<ConstantPoolSDNode>(CPIdx)->getAlignment();
index 94dc3ed4755007533df167db06e07a1d51966abc..ff58b221cb0aecb2b6f7ef547a92865d583a03c0 100644 (file)
@@ -201,6 +201,7 @@ Constant *ShadowStackGC::GetFrameMap(Function &F) {
       NumMeta = I + 1;
     Metadata.push_back(ConstantExpr::getBitCast(C, VoidPtr));
   }
+  Metadata.resize(NumMeta);
 
   const Type *Int32Ty = Type::getInt32Ty(F.getContext());
   
@@ -211,8 +212,7 @@ Constant *ShadowStackGC::GetFrameMap(Function &F) {
 
   Constant *DescriptorElts[] = {
     ConstantStruct::get(StructType::get(Int32Ty, Int32Ty, NULL), BaseElts),
-    ConstantArray::get(ArrayType::get(VoidPtr, NumMeta),
-                       Metadata.begin(), NumMeta)
+    ConstantArray::get(ArrayType::get(VoidPtr, NumMeta), Metadata)
   };
 
   Constant *FrameMap =
index b90221301041147e9e2ded2ca6011862bf166e0c..07d69e8f36a86327f8b5746e6f197f0b0b71ab59 100644 (file)
@@ -561,11 +561,11 @@ GlobalVariable *GCOVProfiler::buildEdgeLookupTable(
     Edge += Successors;
   }
 
+  ArrayRef<Constant*> V(&EdgeTable[0], Succs.size() * Preds.size());
   GlobalVariable *EdgeTableGV =
       new GlobalVariable(
           *M, EdgeTableTy, true, GlobalValue::InternalLinkage,
-          ConstantArray::get(EdgeTableTy,
-                             &EdgeTable[0], Succs.size() * Preds.size()),
+          ConstantArray::get(EdgeTableTy, V),
           "__llvm_gcda_edge_table");
   EdgeTableGV->setUnnamedAddr(true);
   return EdgeTableGV;
index 2fee173a1f747451a37362a6137c9064e4beb63f..87f2fe624e5923a85ddea1121c2eda37e06d5b79 100644 (file)
@@ -571,8 +571,7 @@ ConstantArray::ConstantArray(const ArrayType *T,
   }
 }
 
-Constant *ConstantArray::get(const ArrayType *Ty, 
-                             const std::vector<Constant*> &V) {
+Constant *ConstantArray::get(const ArrayType *Ty, ArrayRef<Constant*> V) {
   for (unsigned i = 0, e = V.size(); i != e; ++i) {
     assert(V[i]->getType() == Ty->getElementType() &&
            "Wrong type in array element initializer");
@@ -592,13 +591,6 @@ Constant *ConstantArray::get(const ArrayType *Ty,
   return ConstantAggregateZero::get(Ty);
 }
 
-
-Constant *ConstantArray::get(const ArrayType* T, Constant *const* Vals,
-                             unsigned NumVals) {
-  // FIXME: make this the primary ctor method.
-  return get(T, std::vector<Constant*>(Vals, Vals+NumVals));
-}
-
 /// ConstantArray::get(const string&) - Return an array that is initialized to
 /// contain the specified string.  If length is zero then a null terminator is 
 /// added to the specified string so that it may be used in a natural way. 
index 16ccc7b8938ed1f72d922dcb370873af5df1f2e5..bdd988e7b0807df3c685f1fc7f9d9f8c102e0f03 100644 (file)
@@ -625,9 +625,8 @@ LLVMValueRef LLVMConstString(const char *Str, unsigned Length,
 }
 LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy,
                             LLVMValueRef *ConstantVals, unsigned Length) {
-  return wrap(ConstantArray::get(ArrayType::get(unwrap(ElementTy), Length),
-                                 unwrap<Constant>(ConstantVals, Length),
-                                 Length));
+  ArrayRef<Constant*> V(unwrap<Constant>(ConstantVals, Length), Length);
+  return wrap(ConstantArray::get(ArrayType::get(unwrap(ElementTy), Length), V));
 }
 LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count,
                              LLVMBool Packed) {