1 //===- llvm/Analysis/MemoryBuiltins.h- Calls to memory builtins -*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This family of functions identifies calls to builtin functions that allocate
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_ANALYSIS_MEMORYBUILTINS_H
16 #define LLVM_ANALYSIS_MEMORYBUILTINS_H
25 //===----------------------------------------------------------------------===//
26 // malloc Call Utility Functions.
29 /// isMalloc - Returns true if the value is either a malloc call or a bitcast of
30 /// the result of a malloc call
31 bool isMalloc(const Value *I);
33 /// extractMallocCall - Returns the corresponding CallInst if the instruction
34 /// is a malloc call. Since CallInst::CreateMalloc() only creates calls, we
35 /// ignore InvokeInst here.
36 const CallInst* extractMallocCall(const Value *I);
37 CallInst* extractMallocCall(Value *I);
39 /// extractMallocCallFromBitCast - Returns the corresponding CallInst if the
40 /// instruction is a bitcast of the result of a malloc call.
41 const CallInst* extractMallocCallFromBitCast(const Value *I);
42 CallInst* extractMallocCallFromBitCast(Value *I);
44 /// isArrayMalloc - Returns the corresponding CallInst if the instruction
45 /// is a call to malloc whose array size can be determined and the array size
46 /// is not constant 1. Otherwise, return NULL.
47 CallInst* isArrayMalloc(Value *I, const TargetData *TD);
48 const CallInst* isArrayMalloc(const Value *I,
49 const TargetData *TD);
51 /// getMallocType - Returns the PointerType resulting from the malloc call.
52 /// This PointerType is the result type of the call's only bitcast use.
53 /// If there is no unique bitcast use, then return NULL.
54 const PointerType* getMallocType(const CallInst *CI);
56 /// getMallocAllocatedType - Returns the Type allocated by malloc call. This
57 /// Type is the result type of the call's only bitcast use. If there is no
58 /// unique bitcast use, then return NULL.
59 const Type* getMallocAllocatedType(const CallInst *CI);
61 /// getMallocArraySize - Returns the array size of a malloc call. If the
62 /// argument passed to malloc is a multiple of the size of the malloced type,
63 /// then return that multiple. For non-array mallocs, the multiple is
64 /// constant 1. Otherwise, return NULL for mallocs whose array size cannot be
66 Value* getMallocArraySize(CallInst *CI, const TargetData *TD);
68 //===----------------------------------------------------------------------===//
69 // free Call Utility Functions.
72 /// isFreeCall - Returns true if the the value is a call to the builtin free()
73 bool isFreeCall(const Value* I);
75 } // End llvm namespace