Use the right method to get the # elements in a CDS.
authorChris Lattner <sabre@nondot.org>
Wed, 25 Jan 2012 01:27:20 +0000 (01:27 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 25 Jan 2012 01:27:20 +0000 (01:27 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148897 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/ConstantFolding.cpp
lib/Analysis/ValueTracking.cpp
lib/CodeGen/AsmPrinter/AsmPrinter.cpp
lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

index 7ee716fdf6299440a421f22309403eb8f598fdcf..43b3af2ac52350234de47ae549f6179d9614d43b 100644 (file)
@@ -351,7 +351,7 @@ static bool ReadDataFromGlobal(Constant *C, uint64_t ByteOffset,
     uint64_t EltSize = CDS->getElementByteSize();
     uint64_t Index = ByteOffset / EltSize;    
     uint64_t Offset = ByteOffset - Index * EltSize;
-    for (; Index != CDS->getType()->getNumElements(); ++Index) {
+    for (unsigned e = CDS->getNumElements(); Index != e; ++Index) {
       if (!ReadDataFromGlobal(CDS->getElementAsConstant(Index), Offset, CurPtr,
                               BytesLeft, TD))
         return false;
@@ -1042,7 +1042,7 @@ Constant *llvm::ConstantFoldLoadThroughGEPIndices(Constant *C,
         return 0;
       C = CA->getOperand(IdxVal);
     } else if (ConstantDataSequential *CDS=dyn_cast<ConstantDataSequential>(C)){
-      if (IdxVal >= CDS->getType()->getNumElements())
+      if (IdxVal >= CDS->getNumElements())
         return 0;
       C = CDS->getElementAsConstant(IdxVal);
     } else if (ConstantVector *CV = dyn_cast<ConstantVector>(C)) {
index 753ec1899443c8c64b5f22782e4352aeb864e9f4..ca55fcbc6edb5002a72ddff57f04bee352758870 100644 (file)
@@ -105,7 +105,7 @@ void llvm::ComputeMaskedBits(Value *V, const APInt &Mask,
     // each element.
     KnownZero.setAllBits(); KnownOne.setAllBits();
     APInt Elt(KnownZero.getBitWidth(), 0);
-    for (unsigned i = 0, e = CDS->getType()->getNumElements(); i != e; ++i) {
+    for (unsigned i = 0, e = CDS->getNumElements(); i != e; ++i) {
       Elt = CDS->getElementAsInteger(i);
       KnownZero &= ~Elt;
       KnownOne &= Elt;      
index ff6da1248bbd1269ad1a6dd3923c89c871b3d184..0e6c613f93ba06122cbda73525a988e98bd548b4 100644 (file)
@@ -1630,7 +1630,7 @@ static void EmitGlobalConstantDataSequential(const ConstantDataSequential *CDS,
   // Otherwise, emit the values in successive locations.
   unsigned ElementByteSize = CDS->getElementByteSize();
   if (isa<IntegerType>(CDS->getElementType())) {
-    for (unsigned i = 0, e = CDS->getType()->getNumElements(); i != e; ++i) {
+    for (unsigned i = 0, e = CDS->getNumElements(); i != e; ++i) {
       AP.OutStreamer.EmitIntValue(CDS->getElementAsInteger(i),
                                   ElementByteSize, AddrSpace);
     }
@@ -1643,7 +1643,7 @@ static void EmitGlobalConstantDataSequential(const ConstantDataSequential *CDS,
          CDS->getElementType()->isDoubleTy());
 
   if (ElementByteSize == 4) {
-    for (unsigned i = 0, e = CDS->getType()->getNumElements(); i != e; ++i) {
+    for (unsigned i = 0, e = CDS->getNumElements(); i != e; ++i) {
       union {
         float F;
         uint32_t I;
@@ -1657,7 +1657,7 @@ static void EmitGlobalConstantDataSequential(const ConstantDataSequential *CDS,
     return;
   }
 
-  for (unsigned i = 0, e = CDS->getType()->getNumElements(); i != e; ++i) {
+  for (unsigned i = 0, e = CDS->getNumElements(); i != e; ++i) {
     union {
       double F;
       uint64_t I;
index cd9bec11bd059e248b219bde3b1de0def966c017..7731f7c6b2885582d3fbcb9d3e8afe25efc1c3bf 100644 (file)
@@ -1059,7 +1059,7 @@ SDValue SelectionDAGBuilder::getValueImpl(const Value *V) {
     if (const ConstantDataSequential *CDS =
           dyn_cast<ConstantDataSequential>(C)) {
       SmallVector<SDValue, 4> Ops;
-      for (unsigned i = 0, e = CDS->getType()->getNumElements(); i != e; ++i) {
+      for (unsigned i = 0, e = CDS->getNumElements(); i != e; ++i) {
         SDNode *Val = getValue(CDS->getElementAsConstant(i)).getNode();
         // Add each leaf value from the operand to the Constants list
         // to form a flattened list of all the values.