|
LLVM 24.0.0git
|
#include "llvm/Analysis/MemoryBuiltins.h"#include "llvm/ADT/APInt.h"#include "llvm/ADT/STLExtras.h"#include "llvm/ADT/Statistic.h"#include "llvm/Analysis/AliasAnalysis.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/ProfDataUtils.h"#include "llvm/IR/Type.h"#include "llvm/IR/Value.h"#include "llvm/Support/Casting.h"#include "llvm/Support/CommandLine.h"#include "llvm/Support/Debug.h"#include "llvm/Support/MathExtras.h"#include "llvm/Support/raw_ostream.h"#include <cassert>#include <cstdint>#include <iterator>#include <numeric>#include <optional>#include <utility>Go to the source code of this file.
Namespaces | |
| namespace | llvm |
| This is an optimization pass for GlobalISel generic memory operations. | |
Macros | |
| #define | DEBUG_TYPE "memory-builtins" |
Functions | |
| static bool | isStrNDupLike (LibFunc LF) |
| static bool | isStrDupLike (LibFunc LF) |
| static std::pair< Value *, Value * > | getAllocSizePair (const CallBase *CB) |
| static AllocFnKind | getAllocFnKind (const Value *V) |
| static AllocFnKind | getAllocFnKind (const Function *F) |
| static bool | checkFnAllocKind (const Value *V, AllocFnKind Wanted) |
| static bool | checkFnAllocKind (const Function *F, AllocFnKind Wanted) |
| static bool | checkedZextOrTrunc (APInt &I, unsigned IntTyBits) |
| When we're compiling N-bit code, and the user uses parameters that are greater than N bits (e.g. | |
| static APInt | getSizeWithOverflow (const SizeOffsetAPInt &Data) |
| STATISTIC (ObjectVisitorArgument, "Number of arguments with unsolved size and offset") | |
| STATISTIC (ObjectVisitorLoad, "Number of load instructions with unsolved size and offset") | |
| static std::optional< APInt > | combinePossibleConstantValues (std::optional< APInt > LHS, std::optional< APInt > RHS, ObjectSizeOpts::Mode EvalMode) |
| static std::optional< APInt > | aggregatePossibleConstantValuesImpl (const Value *V, ObjectSizeOpts::Mode EvalMode, unsigned BitWidth, unsigned RecursionDepth) |
| static std::optional< APInt > | aggregatePossibleConstantValues (const Value *V, ObjectSizeOpts::Mode EvalMode, unsigned BitWidth) |
Variables | |
| static cl::opt< unsigned > | ObjectSizeOffsetVisitorMaxVisitInstructions ("object-size-offset-visitor-max-visit-instructions", cl::desc("Maximum number of instructions for ObjectSizeOffsetVisitor to " "look at"), cl::init(100)) |
| #define DEBUG_TYPE "memory-builtins" |
Definition at line 52 of file MemoryBuiltins.cpp.
|
static |
Definition at line 496 of file MemoryBuiltins.cpp.
References aggregatePossibleConstantValuesImpl(), llvm::BitWidth, llvm::dyn_cast(), llvm::ObjectSizeOpts::Max, llvm::ObjectSizeOpts::Min, and V.
Referenced by llvm::ObjectSizeOffsetVisitor::visitAllocaInst(), and llvm::ObjectSizeOffsetVisitor::visitCallBase().
|
static |
Definition at line 462 of file MemoryBuiltins.cpp.
References aggregatePossibleConstantValuesImpl(), llvm::BitWidth, combinePossibleConstantValues(), llvm::Count, llvm::dyn_cast(), I, and V.
Referenced by aggregatePossibleConstantValues(), and aggregatePossibleConstantValuesImpl().
When we're compiling N-bit code, and the user uses parameters that are greater than N bits (e.g.
uint64_t on a 32-bit build), we can run into trouble with APInt size issues. This function handles resizing + overflow checks for us. Check and zext or trunc I depending on IntTyBits and I's value.
Definition at line 156 of file MemoryBuiltins.cpp.
References I.
Referenced by llvm::getAllocSize().
|
static |
Definition at line 101 of file MemoryBuiltins.cpp.
References F, getAllocFnKind(), and llvm::Unknown.
|
static |
Definition at line 97 of file MemoryBuiltins.cpp.
References getAllocFnKind(), llvm::Unknown, and V.
Referenced by llvm::getAllocationFamily(), llvm::getElidedFreeResult(), llvm::getFreedOperand(), llvm::getReallocatedOperand(), llvm::isAllocationFn(), llvm::isAllocLikeFn(), llvm::isFreeLikeFn(), and llvm::isReallocLikeFn().
|
static |
Definition at line 452 of file MemoryBuiltins.cpp.
References LHS, llvm::ObjectSizeOpts::Max, and RHS.
Referenced by aggregatePossibleConstantValuesImpl().
|
static |
Definition at line 93 of file MemoryBuiltins.cpp.
References F.
|
static |
Definition at line 84 of file MemoryBuiltins.cpp.
References llvm::dyn_cast(), llvm::Attribute::getValueAsInt(), llvm::Attribute::isValid(), llvm::Unknown, and V.
Referenced by checkFnAllocKind(), checkFnAllocKind(), and llvm::getInitialValueOfAllocation().
Definition at line 73 of file MemoryBuiltins.cpp.
References llvm::Attribute::getAllocSizeArgs(), llvm::CallBase::getArgOperand(), llvm::CallBase::getFnAttr(), and llvm::Attribute::isValid().
Referenced by llvm::getAllocSize(), and llvm::ObjectSizeOffsetEvaluator::visitCallBase().
|
static |
Definition at line 289 of file MemoryBuiltins.cpp.
References llvm::Data, llvm::APInt::getZero(), llvm::Offset, and llvm::Size.
Referenced by llvm::getObjectSize().
|
static |
Definition at line 68 of file MemoryBuiltins.cpp.
References isStrNDupLike().
Referenced by llvm::getAllocSize().
|
static |
Definition at line 64 of file MemoryBuiltins.cpp.
Referenced by llvm::getAllocSize(), and isStrDupLike().
| STATISTIC | ( | ObjectVisitorArgument | , |
| "Number of arguments with unsolved size and offset" | ) |
| STATISTIC | ( | ObjectVisitorLoad | , |
| "Number of load instructions with unsolved size and offset" | ) |
|
static |