diff options
author | Chris Lattner <sabre@nondot.org> | 2012-01-25 01:27:20 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2012-01-25 01:27:20 +0000 |
commit | 9be59599b3b17be04d92a86b4bc11631e554a0d5 (patch) | |
tree | ad99cba3a715c18d491c21467b2be9a7677e52b3 /llvm/lib/Analysis/ConstantFolding.cpp | |
parent | dd99ec8ccf542bfde5fe60eb23ad58e5bbf1b790 (diff) | |
download | llvm-9be59599b3b17be04d92a86b4bc11631e554a0d5.zip llvm-9be59599b3b17be04d92a86b4bc11631e554a0d5.tar.gz llvm-9be59599b3b17be04d92a86b4bc11631e554a0d5.tar.bz2 |
Use the right method to get the # elements in a CDS.
llvm-svn: 148897
Diffstat (limited to 'llvm/lib/Analysis/ConstantFolding.cpp')
-rw-r--r-- | llvm/lib/Analysis/ConstantFolding.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp index 7ee716f..43b3af2 100644 --- a/llvm/lib/Analysis/ConstantFolding.cpp +++ b/llvm/lib/Analysis/ConstantFolding.cpp @@ -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)) { |