14#include "llvm/IR/IntrinsicsARM.h"
20 OS <<
"LocationSize::";
22 OS <<
"beforeOrAfterPointer";
45 const auto &
DL = SI->getDataLayout();
49 SI->getValueOperand()->getType())),
76std::optional<MemoryLocation>
79 case Instruction::Load:
80 return get(cast<LoadInst>(Inst));
81 case Instruction::Store:
82 return get(cast<StoreInst>(Inst));
83 case Instruction::VAArg:
84 return get(cast<VAArgInst>(Inst));
85 case Instruction::AtomicCmpXchg:
86 return get(cast<AtomicCmpXchgInst>(Inst));
87 case Instruction::AtomicRMW:
88 return get(cast<AtomicRMWInst>(Inst));
116 assert(
MI->getRawDest() ==
MI->getArgOperand(0));
120std::optional<MemoryLocation>
129 Value *UsedV =
nullptr;
130 std::optional<unsigned> UsedIdx;
131 for (
unsigned i = 0; i < CB->
arg_size(); i++) {
142 UsedIdx = std::nullopt;
163 const Value *Arg = Call->getArgOperand(ArgIdx);
169 switch (
II->getIntrinsicID()) {
172 case Intrinsic::memset:
173 case Intrinsic::memcpy:
174 case Intrinsic::memcpy_inline:
175 case Intrinsic::memmove:
176 case Intrinsic::memcpy_element_unordered_atomic:
177 case Intrinsic::memmove_element_unordered_atomic:
178 case Intrinsic::memset_element_unordered_atomic:
179 assert((ArgIdx == 0 || ArgIdx == 1) &&
180 "Invalid argument index for memory intrinsic");
181 if (
ConstantInt *LenCI = dyn_cast<ConstantInt>(
II->getArgOperand(2)))
186 case Intrinsic::experimental_memset_pattern:
187 assert((ArgIdx == 0 || ArgIdx == 1) &&
188 "Invalid argument index for memory intrinsic");
189 if (
ConstantInt *LenCI = dyn_cast<ConstantInt>(
II->getArgOperand(2)))
193 LenCI->getZExtValue() *
194 DL.getTypeAllocSize(
II->getArgOperand(1)->getType())),
198 case Intrinsic::lifetime_start:
199 case Intrinsic::lifetime_end:
200 case Intrinsic::invariant_start:
201 assert(ArgIdx == 1 &&
"Invalid argument index");
205 cast<ConstantInt>(
II->getArgOperand(0))->getZExtValue()),
208 case Intrinsic::masked_load:
209 assert(ArgIdx == 0 &&
"Invalid argument index");
215 case Intrinsic::masked_store:
216 assert(ArgIdx == 1 &&
"Invalid argument index");
220 DL.getTypeStoreSize(
II->getArgOperand(0)->getType())),
223 case Intrinsic::invariant_end:
228 assert(ArgIdx == 2 &&
"Invalid argument index");
232 cast<ConstantInt>(
II->getArgOperand(1))->getZExtValue()),
235 case Intrinsic::arm_neon_vld1:
236 assert(ArgIdx == 0 &&
"Invalid argument index");
243 case Intrinsic::arm_neon_vst1:
244 assert(ArgIdx == 0 &&
"Invalid argument index");
247 II->getArgOperand(1)->getType())),
252 !isa<AnyMemTransferInst>(
II) &&
253 "all memory transfer intrinsics should be handled by the switch above");
265 case LibFunc_strncat:
266 assert((ArgIdx == 0 || ArgIdx == 1) &&
"Invalid argument index for str function");
269 case LibFunc_memset_chk:
270 assert(ArgIdx == 0 &&
"Invalid argument index for memset_chk");
272 case LibFunc_memcpy_chk: {
273 assert((ArgIdx == 0 || ArgIdx == 1) &&
274 "Invalid argument index for memcpy_chk");
276 if (
const auto *Len = dyn_cast<ConstantInt>(Call->getArgOperand(2))) {
284 case LibFunc_strncpy: {
285 assert((ArgIdx == 0 || ArgIdx == 1) &&
286 "Invalid argument index for strncpy");
288 if (
const auto *Len = dyn_cast<ConstantInt>(Call->getArgOperand(2))) {
296 case LibFunc_memset_pattern16:
297 case LibFunc_memset_pattern4:
298 case LibFunc_memset_pattern8:
299 assert((ArgIdx == 0 || ArgIdx == 1) &&
300 "Invalid argument index for memset_pattern16");
303 if (
F == LibFunc_memset_pattern4)
305 else if (
F == LibFunc_memset_pattern8)
310 dyn_cast<ConstantInt>(Call->getArgOperand(2)))
316 assert((ArgIdx == 0 || ArgIdx == 1) &&
317 "Invalid argument index for memcmp/bcmp");
319 dyn_cast<ConstantInt>(Call->getArgOperand(2)))
324 assert((ArgIdx == 0) &&
"Invalid argument index for memchr");
326 dyn_cast<ConstantInt>(Call->getArgOperand(2)))
330 case LibFunc_memccpy:
331 assert((ArgIdx == 0 || ArgIdx == 1) &&
332 "Invalid argument index for memccpy");
335 dyn_cast<ConstantInt>(Call->getArgOperand(3)))
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
This file provides utility analysis objects describing memory locations.
uint64_t IntrinsicInst * II
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
An instruction that atomically checks whether a specified value is in a memory location,...
Value * getCompareOperand()
Value * getPointerOperand()
an instruction that atomically reads a memory location, combines it with another value,...
Value * getPointerOperand()
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
bool onlyReadsMemory(unsigned OpNo) const
Value * getArgOperand(unsigned i) const
bool onlyAccessesArgMemory() const
Determine if the call can access memmory only using pointers based on its arguments.
unsigned arg_size() const
bool hasOperandBundles() const
Return true if this User has any operand bundles.
This is the shared class of boolean and integer constants.
A parsed version of the target data layout string in and methods for querying it.
AAMDNodes getAAMetadata() const
Returns the AA metadata for this instruction.
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
const DataLayout & getDataLayout() const
Get the data layout of the module this instruction belongs to.
A wrapper class for inspecting calls to intrinsic functions.
An instruction for reading from memory.
Value * getPointerOperand()
static LocationSize precise(uint64_t Value)
static constexpr LocationSize mapEmpty()
static constexpr LocationSize beforeOrAfterPointer()
Any location before or after the base pointer (but still within the underlying object).
TypeSize getValue() const
void print(raw_ostream &OS) const
static constexpr LocationSize afterPointer()
Any location after the base pointer (but still within the underlying object).
static LocationSize upperBound(uint64_t Value)
static constexpr LocationSize mapTombstone()
This is the common base class for memset/memcpy/memmove.
Value * getRawSource() const
Return the arguments to the instruction.
This class wraps the llvm.memcpy/memmove intrinsics.
Representation for a specific memory location.
static MemoryLocation get(const LoadInst *LI)
Return a location with information about the memory reference by the given instruction.
static MemoryLocation getForSource(const MemTransferInst *MTI)
Return a location representing the source of a memory transfer.
LocationSize Size
The maximum size of the location, in address-units, or UnknownSize if the size is not known.
static MemoryLocation getBeforeOrAfter(const Value *Ptr, const AAMDNodes &AATags=AAMDNodes())
Return a location that may access any location before or after Ptr, while remaining within the underl...
static MemoryLocation getAfter(const Value *Ptr, const AAMDNodes &AATags=AAMDNodes())
Return a location that may access any location after Ptr, while remaining within the underlying objec...
AAMDNodes AATags
The metadata nodes which describes the aliasing of the location (each member is null if that kind of ...
static MemoryLocation getForDest(const MemIntrinsic *MI)
Return a location representing the destination of a memory set or transfer.
static std::optional< MemoryLocation > getOrNone(const Instruction *Inst)
static MemoryLocation getForArgument(const CallBase *Call, unsigned ArgIdx, const TargetLibraryInfo *TLI)
Return a location representing a particular argument of a call.
An instruction for storing to memory.
Provides information about what library functions are available for the current target.
bool has(LibFunc F) const
Tests whether a library function is available.
bool getLibFunc(StringRef funcName, LibFunc &F) const
Searches for a particular function name.
bool isPointerTy() const
True if this is an instance of PointerType.
This class represents the va_arg llvm instruction, which returns an argument of the specified type gi...
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
This class implements an extremely fast bulk output stream that can only output to a stream.
This is an optimization pass for GlobalISel generic memory operations.
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...