Enhance analysis passes so that they apply the same analysis to malloc calls as to MallocInst.

Reviewed by Eli Friedman.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82281 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Victor Hernandez
2009-09-18 21:34:51 +00:00
parent d268e00938
commit 46e8312fb7
5 changed files with 50 additions and 12 deletions
+9
View File
@@ -13,6 +13,7 @@
#include "llvm/Analysis/ConstantFolding.h"
#include "llvm/Analysis/Dominators.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/MallocHelper.h"
#include "llvm/Analysis/PointerTracking.h"
#include "llvm/Analysis/ScalarEvolution.h"
#include "llvm/Analysis/ScalarEvolutionExpressions.h"
@@ -99,6 +100,14 @@ const SCEV *PointerTracking::computeAllocationCount(Value *P,
return SE->getSCEV(arraySize);
}
if (CallInst *CI = extractMallocCall(V)) {
Value *arraySize = getMallocArraySize(CI, P->getContext(), TD);
Ty = getMallocAllocatedType(CI);
if (!Ty || !arraySize) return SE->getCouldNotCompute();
// arraySize elements of type Ty.
return SE->getSCEV(arraySize);
}
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(V)) {
if (GV->hasDefinitiveInitializer()) {
Constant *C = GV->getInitializer();