summaryrefslogtreecommitdiff
path: root/include/llvm/Analysis/MemoryBuiltins.h
diff options
context:
space:
mode:
authorVictor Hernandez <vhernandez@apple.com>2009-10-28 20:18:55 +0000
committerVictor Hernandez <vhernandez@apple.com>2009-10-28 20:18:55 +0000
commit90f48e7c91a8faa875ba889ca66b137ffd46e34a (patch)
treeaa65e67f70dcc037d749a7a91ab809becdeafc87 /include/llvm/Analysis/MemoryBuiltins.h
parent5c00b4af61bb6abff2fb28ddd904808623a7db23 (diff)
downloadllvm-90f48e7c91a8faa875ba889ca66b137ffd46e34a.tar.gz
llvm-90f48e7c91a8faa875ba889ca66b137ffd46e34a.tar.bz2
llvm-90f48e7c91a8faa875ba889ca66b137ffd46e34a.tar.xz
Extend getMallocArraySize() to determine the array size if the malloc argument is:
ArraySize * ElementSize ElementSize * ArraySize ArraySize << log2(ElementSize) ElementSize << log2(ArraySize) Refactor isArrayMallocHelper and delete isSafeToGetMallocArraySize, so that there is only 1 copy of the malloc array determining logic. Update users of getMallocArraySize() to not bother calling isArrayMalloc() as well. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85421 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Analysis/MemoryBuiltins.h')
-rw-r--r--include/llvm/Analysis/MemoryBuiltins.h25
1 files changed, 6 insertions, 19 deletions
diff --git a/include/llvm/Analysis/MemoryBuiltins.h b/include/llvm/Analysis/MemoryBuiltins.h
index 6395d29c68..5fd0bb09db 100644
--- a/include/llvm/Analysis/MemoryBuiltins.h
+++ b/include/llvm/Analysis/MemoryBuiltins.h
@@ -43,15 +43,8 @@ const CallInst* extractMallocCallFromBitCast(const Value* I);
CallInst* extractMallocCallFromBitCast(Value* I);
/// isArrayMalloc - Returns the corresponding CallInst if the instruction
-/// matches the malloc call IR generated by CallInst::CreateMalloc(). This
-/// means that it is a malloc call with one bitcast use AND the malloc call's
-/// size argument is:
-/// 1. a constant not equal to the size of the malloced type
-/// or
-/// 2. the result of a multiplication by the size of the malloced type
-/// Otherwise it returns NULL.
-/// The unique bitcast is needed to determine the type/size of the array
-/// allocation.
+/// is a call to malloc whose array size can be determined and the array size
+/// is not constant 1. Otherwise, return NULL.
CallInst* isArrayMalloc(Value* I, LLVMContext &Context, const TargetData* TD);
const CallInst* isArrayMalloc(const Value* I, LLVMContext &Context,
const TargetData* TD);
@@ -66,16 +59,10 @@ const PointerType* getMallocType(const CallInst* CI);
/// unique bitcast use, then return NULL.
const Type* getMallocAllocatedType(const CallInst* CI);
-/// getMallocArraySize - Returns the array size of a malloc call. For array
-/// mallocs, the size is computated in 1 of 3 ways:
-/// 1. If the element type is of size 1, then array size is the argument to
-/// malloc.
-/// 2. Else if the malloc's argument is a constant, the array size is that
-/// argument divided by the element type's size.
-/// 3. Else the malloc argument must be a multiplication and the array size is
-/// the first operand of the multiplication.
-/// For non-array mallocs, the computed size is constant 1.
-/// This function returns NULL for all mallocs whose array size cannot be
+/// getMallocArraySize - Returns the array size of a malloc call. If the
+/// argument passed to malloc is a multiple of the size of the malloced type,
+/// then return that multiple. For non-array mallocs, the multiple is
+/// constant 1. Otherwise, return NULL for mallocs whose array size cannot be
/// determined.
Value* getMallocArraySize(CallInst* CI, LLVMContext &Context,
const TargetData* TD);