aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/PointerTracking.cpp
diff options
context:
space:
mode:
authorVictor Hernandez <vhernandez@apple.com>2009-10-15 20:14:52 +0000
committerVictor Hernandez <vhernandez@apple.com>2009-10-15 20:14:52 +0000
commit2491ce03535cf8ec171570d2e28df63e4db3dd6b (patch)
treef989d52d9bee2406d249320485604cfc15d171b1 /lib/Analysis/PointerTracking.cpp
parent5814fefc7f27caba408d75194a40d880c64eaac6 (diff)
Fix bug where array malloc with unexpected computation of the size argument resulted in MallocHelper
identifying the malloc as a non-array malloc. This broke GlobalOpt's optimization of stores of mallocs to global variables. The fix is to classify malloc's into 3 categories: 1. non-array mallocs 2. array mallocs whose array size can be determined 3. mallocs that cannot be determined to be of type 1 or 2 and cannot be optimized getMallocArraySize() returns NULL for category 3, and all users of this function must avoid their malloc optimization if this function returns NULL. Eventually, currently unexpected codegen for computing the malloc's size argument will be supported in isArrayMalloc() and getMallocArraySize(), extending malloc optimizations to those examples. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84199 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/PointerTracking.cpp')
-rw-r--r--lib/Analysis/PointerTracking.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/Analysis/PointerTracking.cpp b/lib/Analysis/PointerTracking.cpp
index 43f4af36d8..2309fbc952 100644
--- a/lib/Analysis/PointerTracking.cpp
+++ b/lib/Analysis/PointerTracking.cpp
@@ -102,8 +102,9 @@ const SCEV *PointerTracking::computeAllocationCount(Value *P,
if (CallInst *CI = extractMallocCall(V)) {
Value *arraySize = getMallocArraySize(CI, P->getContext(), TD);
- Ty = getMallocAllocatedType(CI);
- if (!Ty || !arraySize) return SE->getCouldNotCompute();
+ const Type* AllocTy = getMallocAllocatedType(CI);
+ if (!AllocTy || !arraySize) return SE->getCouldNotCompute();
+ Ty = AllocTy;
// arraySize elements of type Ty.
return SE->getSCEV(arraySize);
}