aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Analysis/PointerTracking.cpp
diff options
context:
space:
mode:
authorVictor Hernandez <vhernandez@apple.com>2009-09-18 21:34:51 +0000
committerVictor Hernandez <vhernandez@apple.com>2009-09-18 21:34:51 +0000
commit82f0ab64c43dcae28ed4f0cb4b8bb69df0b4561d (patch)
tree3df531bf95fc9a345c0c0b79a9eb8825dc0dfe89 /lib/Analysis/PointerTracking.cpp
parent3c5ec3c11bd3283bfd8bbf7ce12bb81b8d3e3ed0 (diff)
downloadexternal_llvm-82f0ab64c43dcae28ed4f0cb4b8bb69df0b4561d.tar.gz
external_llvm-82f0ab64c43dcae28ed4f0cb4b8bb69df0b4561d.tar.bz2
external_llvm-82f0ab64c43dcae28ed4f0cb4b8bb69df0b4561d.zip
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
Diffstat (limited to 'lib/Analysis/PointerTracking.cpp')
-rw-r--r--lib/Analysis/PointerTracking.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/Analysis/PointerTracking.cpp b/lib/Analysis/PointerTracking.cpp
index e098647887..22818369b8 100644
--- a/lib/Analysis/PointerTracking.cpp
+++ b/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();