diff options
author | Victor Hernandez <vhernandez@apple.com> | 2009-09-18 21:34:51 +0000 |
---|---|---|
committer | Victor Hernandez <vhernandez@apple.com> | 2009-09-18 21:34:51 +0000 |
commit | 537d8d99be3c25b74c1cd090c9acbf9bda2d97f6 (patch) | |
tree | e9416ab784cf5289cb8e9fd232d28f614c5a8eef /llvm/lib/Analysis/PointerTracking.cpp | |
parent | 51f544240366c99ff8f722c7b4d54eb5ea285da0 (diff) | |
download | bcm5719-llvm-537d8d99be3c25b74c1cd090c9acbf9bda2d97f6.tar.gz bcm5719-llvm-537d8d99be3c25b74c1cd090c9acbf9bda2d97f6.zip |
Enhance analysis passes so that they apply the same analysis to malloc calls as to MallocInst.
Reviewed by Eli Friedman.
llvm-svn: 82281
Diffstat (limited to 'llvm/lib/Analysis/PointerTracking.cpp')
-rw-r--r-- | llvm/lib/Analysis/PointerTracking.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/PointerTracking.cpp b/llvm/lib/Analysis/PointerTracking.cpp index e098647887b..22818369b8b 100644 --- a/llvm/lib/Analysis/PointerTracking.cpp +++ b/llvm/lib/Analysis/PointerTracking.cpp @@ -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(); |