|
LLVM
8.0.1
|
#include "llvm/Analysis/MemoryBuiltins.h"#include "llvm/ADT/APInt.h"#include "llvm/ADT/None.h"#include "llvm/ADT/Optional.h"#include "llvm/ADT/STLExtras.h"#include "llvm/ADT/Statistic.h"#include "llvm/ADT/StringRef.h"#include "llvm/Analysis/TargetFolder.h"#include "llvm/Analysis/TargetLibraryInfo.h"#include "llvm/Analysis/Utils/Local.h"#include "llvm/Analysis/ValueTracking.h"#include "llvm/IR/Argument.h"#include "llvm/IR/Attributes.h"#include "llvm/IR/Constants.h"#include "llvm/IR/DataLayout.h"#include "llvm/IR/DerivedTypes.h"#include "llvm/IR/Function.h"#include "llvm/IR/GlobalAlias.h"#include "llvm/IR/GlobalVariable.h"#include "llvm/IR/Instruction.h"#include "llvm/IR/Instructions.h"#include "llvm/IR/IntrinsicInst.h"#include "llvm/IR/Operator.h"#include "llvm/IR/Type.h"#include "llvm/IR/Value.h"#include "llvm/Support/Casting.h"#include "llvm/Support/Debug.h"#include "llvm/Support/MathExtras.h"#include "llvm/Support/raw_ostream.h"#include <cassert>#include <cstdint>#include <iterator>#include <utility>
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 [] |
| #define DEBUG_TYPE "memory-builtins" |
Definition at line 51 of file MemoryBuiltins.cpp.
| enum AllocType : uint8_t |
| Enumerator | |
|---|---|
| OpNewLike | |
| MallocLike | |
| CallocLike | |
| ReallocLike | |
| StrDupLike | |
| MallocOrCallocLike | |
| AllocLike | |
| AnyAlloc | |
Definition at line 53 of file MemoryBuiltins.cpp.
|
static |
Definition at line 275 of file MemoryBuiltins.cpp.
References llvm::ComputeMultiple(), llvm::CallBase::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 173 of file MemoryBuiltins.cpp.
References Callee, getAllocationDataForFunction(), getCalledFunction(), and llvm::None.
Referenced by llvm::isAllocationFn(), llvm::isAllocLikeFn(), llvm::isCallocLikeFn(), llvm::isMallocLikeFn(), and llvm::isMallocOrCallocLikeFn().
|
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 136 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 184 of file MemoryBuiltins.cpp.
References llvm::Attribute::AllocSize, AllocFnsTy::AllocTy, AnyAlloc, llvm::AMDGPU::HSAMD::Kernel::Key::Args, llvm::Attribute, Callee, llvm::Data, 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 112 of file MemoryBuiltins.cpp.
References Callee, 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::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, IterTy >::isNoBuiltin(), and llvm::Value::stripPointerCasts().
Referenced by CreateGCRelocates(), llvm::StatepointBase< Function, Instruction, Value, CallSite >::doesNotThrow(), getAllocationData(), getAllocationSize(), llvm::CallSiteBase<>::getIntrinsicID(), llvm::CallBase::getIntrinsicID(), llvm::CallBase::getReturnedArgOperand(), llvm::CallBase::hasRetAttr(), llvm::isFreeCall(), llvm::StatepointBase< Function, Instruction, Value, CallSite >::paramHasAttr(), and llvm::CallBase::paramHasAttr().
|
static |
Definition at line 424 of file MemoryBuiltins.cpp.
Referenced by llvm::getObjectSize(), and llvm::ObjectSizeOffsetVisitor::visitSelectInst().
Definition at line 215 of file MemoryBuiltins.cpp.
References llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, IterTy >::hasRetAttr(), llvm::Attribute::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" | |||
| ) |
|
static |
Definition at line 73 of file MemoryBuiltins.cpp.
Referenced by getAllocationDataForFunction().
1.8.13