Calculate the size of a array allocation correctly.
authorOwen Anderson <resistor@mac.com>
Tue, 10 Jul 2007 20:48:38 +0000 (20:48 +0000)
committerOwen Anderson <resistor@mac.com>
Tue, 10 Jul 2007 20:48:38 +0000 (20:48 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@38511 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/MemoryDependenceAnalysis.cpp

index 4168cd6fb1850e2be59a40288a16e0c1f1674e70..1225ebbe884fb505d8999896dcab1187eacadb07 100644 (file)
@@ -64,7 +64,7 @@ Instruction* MemoryDependenceAnalysis::getCallSiteDependency(CallSite C, bool lo
     } else if (AllocationInst* AI = dyn_cast<AllocationInst>(QI)) {
       pointer = AI;
       if (ConstantInt* C = dyn_cast<ConstantInt>(AI->getArraySize()))
-        pointerSize = C->getZExtValue();
+        pointerSize = C->getZExtValue() * TD.getTypeSize(AI->getAllocatedType());
       else
         pointerSize = ~0UL;
     } else if (VAArgInst* V = dyn_cast<VAArgInst>(QI)) {
@@ -180,7 +180,7 @@ Instruction* MemoryDependenceAnalysis::getDependency(Instruction* query,
     } else if (AllocationInst* AI = dyn_cast<AllocationInst>(QI)) {
       pointer = AI;
       if (ConstantInt* C = dyn_cast<ConstantInt>(AI->getArraySize()))
-        pointerSize = C->getZExtValue();
+        pointerSize = C->getZExtValue() * TD.getTypeSize(AI->getAllocatedType());
       else
         pointerSize = ~0UL;
     } else if (VAArgInst* V = dyn_cast<VAArgInst>(QI)) {