|
LLVM
4.0.0
|
#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"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, AllocLike = MallocLike | CallocLike | StrDupLike, AnyAlloc = AllocLike | ReallocLike } |
Functions | |
| static 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::Func, AllocFnsTy > | AllocationFnData [] |
| #define DEBUG_TYPE "memory-builtins" |
Definition at line 32 of file MemoryBuiltins.cpp.
| enum AllocType : uint8_t |
| Enumerator | |
|---|---|
| OpNewLike | |
| MallocLike | |
| CallocLike | |
| ReallocLike | |
| StrDupLike | |
| AllocLike | |
| AnyAlloc | |
Definition at line 34 of file MemoryBuiltins.cpp.
|
static |
Definition at line 237 of file MemoryBuiltins.cpp.
References llvm::ComputeMultiple(), llvm::CallInst::getArgOperand(), llvm::getMallocAllocatedType(), llvm::StructLayout::getSizeInBytes(), llvm::DataLayout::getStructLayout(), llvm::DataLayout::getTypeAllocSize(), llvm::Type::isSized(), and llvm::ARM_MB::ST.
Referenced by llvm::getMallocArraySize().
|
static |
Definition at line 142 of file MemoryBuiltins.cpp.
References getAllocationDataForFunction(), getCalledFunction(), and llvm::None.
Referenced by llvm::isAllocationFn(), llvm::isAllocLikeFn(), llvm::isCallocLikeFn(), and llvm::isMallocLikeFn().
|
static |
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.
Definition at line 105 of file MemoryBuiltins.cpp.
References AllocationFnData, AllocFnsTy::AllocTy, llvm::sys::path::end(), llvm::find_if(), AllocFnsTy::FstParam, llvm::Type::getContext(), llvm::Function::getFunctionType(), llvm::Type::getInt8PtrTy(), llvm::TargetLibraryInfo::getLibFunc(), llvm::Value::getName(), llvm::FunctionType::getNumParams(), llvm::FunctionType::getParamType(), llvm::FunctionType::getReturnType(), llvm::TargetLibraryInfo::has(), llvm::Type::isIntegerTy(), llvm::None, AllocFnsTy::NumParams, P, and AllocFnsTy::SndParam.
Referenced by getAllocationData(), and getAllocationSize().
|
static |
Definition at line 153 of file MemoryBuiltins.cpp.
References AllocFnsTy::AllocTy, AnyAlloc, AMDGPU::RuntimeMD::KeyName::Args, AllocFnsTy::FstParam, getAllocationDataForFunction(), llvm::Attribute::getAllocSizeArgs(), getCalledFunction(), llvm::Function::getFnAttribute(), llvm::User::getNumOperands(), MallocLike, llvm::None, AllocFnsTy::NumParams, and AllocFnsTy::SndParam.
Referenced by llvm::ObjectSizeOffsetVisitor::visitCallSite(), and llvm::ObjectSizeOffsetEvaluator::visitCallSite().
|
static |
Definition at line 80 of file MemoryBuiltins.cpp.
References llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, IterTy >::getCalledFunction(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, IterTy >::getInstruction(), llvm::GlobalValue::isDeclaration(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, IterTy >::isNoBuiltin(), and llvm::Value::stripPointerCasts().
Referenced by getAllocationData(), and getAllocationSize().
|
static |
Definition at line 386 of file MemoryBuiltins.cpp.
Referenced by llvm::getObjectSize(), and llvm::ObjectSizeOffsetVisitor::visitSelectInst().
Definition at line 184 of file MemoryBuiltins.cpp.
References llvm::NoAlias, llvm::AttributeSet::ReturnIndex, 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" | |||
| ) |
|
static |
Definition at line 53 of file MemoryBuiltins.cpp.
Referenced by getAllocationDataForFunction().
1.8.6