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::lifetime_start:
187 case Intrinsic::lifetime_end:
188 case Intrinsic::invariant_start:
189 assert(ArgIdx == 1 &&
"Invalid argument index");
193 cast<ConstantInt>(
II->getArgOperand(0))->getZExtValue()),
196 case Intrinsic::masked_load:
197 assert(ArgIdx == 0 &&
"Invalid argument index");
203 case Intrinsic::masked_store:
204 assert(ArgIdx == 1 &&
"Invalid argument index");
208 DL.getTypeStoreSize(
II->getArgOperand(0)->getType())),
211 case Intrinsic::invariant_end:
216 assert(ArgIdx == 2 &&
"Invalid argument index");
220 cast<ConstantInt>(
II->getArgOperand(1))->getZExtValue()),
223 case Intrinsic::arm_neon_vld1:
224 assert(ArgIdx == 0 &&
"Invalid argument index");
231 case Intrinsic::arm_neon_vst1:
232 assert(ArgIdx == 0 &&
"Invalid argument index");
235 II->getArgOperand(1)->getType())),
240 !isa<AnyMemTransferInst>(
II) &&
241 "all memory transfer intrinsics should be handled by the switch above");
253 case LibFunc_strncat:
254 assert((ArgIdx == 0 || ArgIdx == 1) &&
"Invalid argument index for str function");
257 case LibFunc_memset_chk:
258 assert(ArgIdx == 0 &&
"Invalid argument index for memset_chk");
260 case LibFunc_memcpy_chk: {
261 assert((ArgIdx == 0 || ArgIdx == 1) &&
262 "Invalid argument index for memcpy_chk");
264 if (
const auto *Len = dyn_cast<ConstantInt>(Call->getArgOperand(2))) {
272 case LibFunc_strncpy: {
273 assert((ArgIdx == 0 || ArgIdx == 1) &&
274 "Invalid argument index for strncpy");
276 if (
const auto *Len = dyn_cast<ConstantInt>(Call->getArgOperand(2))) {
284 case LibFunc_memset_pattern16:
285 case LibFunc_memset_pattern4:
286 case LibFunc_memset_pattern8:
287 assert((ArgIdx == 0 || ArgIdx == 1) &&
288 "Invalid argument index for memset_pattern16");
291 if (
F == LibFunc_memset_pattern4)
293 else if (
F == LibFunc_memset_pattern8)
298 dyn_cast<ConstantInt>(Call->getArgOperand(2)))
304 assert((ArgIdx == 0 || ArgIdx == 1) &&
305 "Invalid argument index for memcmp/bcmp");
307 dyn_cast<ConstantInt>(Call->getArgOperand(2)))
312 assert((ArgIdx == 0) &&
"Invalid argument index for memchr");
314 dyn_cast<ConstantInt>(Call->getArgOperand(2)))
318 case LibFunc_memccpy:
319 assert((ArgIdx == 0 || ArgIdx == 1) &&
320 "Invalid argument index for memccpy");
323 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...