LLVM  5.0.0
Classes | Macros | Enumerations | Functions | Variables
MemoryBuiltins.cpp File Reference
#include "llvm/Analysis/MemoryBuiltins.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/Metadata.h"
#include "llvm/IR/Module.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/Utils/Local.h"
Include dependency graph for MemoryBuiltins.cpp:

Go to the source code of this file.

Classes

struct  AllocFnsTy
 

Macros

#define DEBUG_TYPE   "memory-builtins"
 

Enumerations

enum  AllocType : uint8_t {
  OpNewLike = 1<<0, MallocLike = 1<<1 | OpNewLike, CallocLike = 1<<2, ReallocLike = 1<<3,
  StrDupLike = 1<<4, MallocOrCallocLike = MallocLike | CallocLike, AllocLike = MallocLike | CallocLike | StrDupLike, AnyAlloc = AllocLike | ReallocLike
}
 

Functions

static const Function * getCalledFunction (const Value *V, bool LookThroughBitCast, bool &IsNoBuiltin)
 
static Optional< AllocFnsTy > getAllocationDataForFunction (const Function *Callee, AllocType AllocTy, const TargetLibraryInfo *TLI)
 Returns the allocation data for the given value if it's either a call to a known allocation function, or a call to a function with the allocsize attribute. More...
 
static Optional< AllocFnsTy > getAllocationData (const Value *V, AllocType AllocTy, const TargetLibraryInfo *TLI, bool LookThroughBitCast=false)
 
static Optional< AllocFnsTy > getAllocationSize (const Value *V, const TargetLibraryInfo *TLI)
 
static bool hasNoAliasAttr (const Value *V, bool LookThroughBitCast)
 
static Value * computeArraySize (const CallInst *CI, const DataLayout &DL, const TargetLibraryInfo *TLI, bool LookThroughSExt=false)
 
static APInt getSizeWithOverflow (const SizeOffsetType &Data)
 
 STATISTIC (ObjectVisitorArgument,"Number of arguments with unsolved size and offset")
 
 STATISTIC (ObjectVisitorLoad,"Number of load instructions with unsolved size and offset")
 

Variables

static const std::pair
< LibFunc, AllocFnsTy > 
AllocationFnData []
 

Macro Definition Documentation

#define DEBUG_TYPE   "memory-builtins"

Definition at line 32 of file MemoryBuiltins.cpp.

Enumeration Type Documentation

enum AllocType : uint8_t
Enumerator
OpNewLike 
MallocLike 
CallocLike 
ReallocLike 
StrDupLike 
MallocOrCallocLike 
AllocLike 
AnyAlloc 

Definition at line 34 of file MemoryBuiltins.cpp.

Function Documentation

static Value* computeArraySize ( const CallInst *  CI,
const DataLayout &  DL,
const TargetLibraryInfo *  TLI,
bool  LookThroughSExt = false 
)
static
static Optional<AllocFnsTy> getAllocationData ( const Value *  V,
AllocType  AllocTy,
const TargetLibraryInfo *  TLI,
bool  LookThroughBitCast = false 
)
static
static Optional<AllocFnsTy> getAllocationDataForFunction ( const Function *  Callee,
AllocType  AllocTy,
const TargetLibraryInfo *  TLI 
)
static
static Optional<AllocFnsTy> getAllocationSize ( const Value *  V,
const TargetLibraryInfo *  TLI 
)
static
static const Function* getCalledFunction ( const Value *  V,
bool  LookThroughBitCast,
bool &  IsNoBuiltin 
)
static
static APInt getSizeWithOverflow ( const SizeOffsetType &  Data)
static
static bool hasNoAliasAttr ( const Value *  V,
bool  LookThroughBitCast 
)
static

Definition at line 185 of file MemoryBuiltins.cpp.

References llvm::NoAlias, and llvm::Value::stripPointerCasts().

Referenced by llvm::isNoAliasFn().

STATISTIC ( ObjectVisitorArgument  ,
"Number of arguments with unsolved size and offset"   
)
STATISTIC ( ObjectVisitorLoad  ,
"Number of load instructions with unsolved size and offset"   
)

Variable Documentation

const std::pair<LibFunc, AllocFnsTy> AllocationFnData[]
static
Initial value:
= {
{LibFunc_malloc, {MallocLike, 1, 0, -1}},
{LibFunc_valloc, {MallocLike, 1, 0, -1}},
{LibFunc_Znwj, {OpNewLike, 1, 0, -1}},
{LibFunc_ZnwjRKSt9nothrow_t, {MallocLike, 2, 0, -1}},
{LibFunc_Znwm, {OpNewLike, 1, 0, -1}},
{LibFunc_ZnwmRKSt9nothrow_t, {MallocLike, 2, 0, -1}},
{LibFunc_Znaj, {OpNewLike, 1, 0, -1}},
{LibFunc_ZnajRKSt9nothrow_t, {MallocLike, 2, 0, -1}},
{LibFunc_Znam, {OpNewLike, 1, 0, -1}},
{LibFunc_ZnamRKSt9nothrow_t, {MallocLike, 2, 0, -1}},
{LibFunc_msvc_new_int, {OpNewLike, 1, 0, -1}},
{LibFunc_msvc_new_int_nothrow, {MallocLike, 2, 0, -1}},
{LibFunc_msvc_new_longlong, {OpNewLike, 1, 0, -1}},
{LibFunc_msvc_new_longlong_nothrow, {MallocLike, 2, 0, -1}},
{LibFunc_msvc_new_array_int, {OpNewLike, 1, 0, -1}},
{LibFunc_msvc_new_array_int_nothrow, {MallocLike, 2, 0, -1}},
{LibFunc_msvc_new_array_longlong, {OpNewLike, 1, 0, -1}},
{LibFunc_msvc_new_array_longlong_nothrow, {MallocLike, 2, 0, -1}},
{LibFunc_calloc, {CallocLike, 2, 0, 1}},
{LibFunc_realloc, {ReallocLike, 2, 1, -1}},
{LibFunc_reallocf, {ReallocLike, 2, 1, -1}},
{LibFunc_strdup, {StrDupLike, 1, -1, -1}},
{LibFunc_strndup, {StrDupLike, 2, 1, -1}}
}

Definition at line 54 of file MemoryBuiltins.cpp.

Referenced by getAllocationDataForFunction().