14#include "llvm/IR/IntrinsicsARM.h"
21 OS <<
"LocationSize::";
23 OS <<
"beforeOrAfterPointer";
46 const auto &
DL = SI->getDataLayout();
50 SI->getValueOperand()->getType())),
77std::optional<MemoryLocation>
80 case Instruction::Load:
81 return get(cast<LoadInst>(Inst));
82 case Instruction::Store:
83 return get(cast<StoreInst>(Inst));
84 case Instruction::VAArg:
85 return get(cast<VAArgInst>(Inst));
86 case Instruction::AtomicCmpXchg:
87 return get(cast<AtomicCmpXchgInst>(Inst));
88 case Instruction::AtomicRMW:
89 return get(cast<AtomicRMWInst>(Inst));
117 assert(
MI->getRawDest() ==
MI->getArgOperand(0));
121std::optional<MemoryLocation>
130 Value *UsedV =
nullptr;
131 std::optional<unsigned> UsedIdx;
132 for (
unsigned i = 0; i < CB->
arg_size(); i++) {
143 UsedIdx = std::nullopt;
164 const Value *Arg = Call->getArgOperand(ArgIdx);
170 switch (
II->getIntrinsicID()) {
173 case Intrinsic::memset:
174 case Intrinsic::memcpy:
175 case Intrinsic::memcpy_inline:
176 case Intrinsic::memmove:
177 case Intrinsic::memcpy_element_unordered_atomic:
178 case Intrinsic::memmove_element_unordered_atomic:
179 case Intrinsic::memset_element_unordered_atomic:
180 assert((ArgIdx == 0 || ArgIdx == 1) &&
181 "Invalid argument index for memory intrinsic");
182 if (
ConstantInt *LenCI = dyn_cast<ConstantInt>(
II->getArgOperand(2)))
187 case Intrinsic::lifetime_start:
188 case Intrinsic::lifetime_end:
189 case Intrinsic::invariant_start:
190 assert(ArgIdx == 1 &&
"Invalid argument index");
194 cast<ConstantInt>(
II->getArgOperand(0))->getZExtValue()),
197 case Intrinsic::masked_load:
198 assert(ArgIdx == 0 &&
"Invalid argument index");
204 case Intrinsic::masked_store:
205 assert(ArgIdx == 1 &&
"Invalid argument index");
209 DL.getTypeStoreSize(
II->getArgOperand(0)->getType())),
212 case Intrinsic::invariant_end:
217 assert(ArgIdx == 2 &&
"Invalid argument index");
221 cast<ConstantInt>(
II->getArgOperand(1))->getZExtValue()),
224 case Intrinsic::arm_neon_vld1:
225 assert(ArgIdx == 0 &&
"Invalid argument index");
232 case Intrinsic::arm_neon_vst1:
233 assert(ArgIdx == 0 &&
"Invalid argument index");
236 II->getArgOperand(1)->getType())),
241 !isa<AnyMemTransferInst>(
II) &&
242 "all memory transfer intrinsics should be handled by the switch above");
254 case LibFunc_strncat:
255 assert((ArgIdx == 0 || ArgIdx == 1) &&
"Invalid argument index for str function");
258 case LibFunc_memset_chk:
259 assert(ArgIdx == 0 &&
"Invalid argument index for memset_chk");
261 case LibFunc_memcpy_chk: {
262 assert((ArgIdx == 0 || ArgIdx == 1) &&
263 "Invalid argument index for memcpy_chk");
265 if (
const auto *Len = dyn_cast<ConstantInt>(Call->getArgOperand(2))) {
273 case LibFunc_strncpy: {
274 assert((ArgIdx == 0 || ArgIdx == 1) &&
275 "Invalid argument index for strncpy");
277 if (
const auto *Len = dyn_cast<ConstantInt>(Call->getArgOperand(2))) {
285 case LibFunc_memset_pattern16:
286 case LibFunc_memset_pattern4:
287 case LibFunc_memset_pattern8:
288 assert((ArgIdx == 0 || ArgIdx == 1) &&
289 "Invalid argument index for memset_pattern16");
292 if (
F == LibFunc_memset_pattern4)
294 else if (
F == LibFunc_memset_pattern8)
299 dyn_cast<ConstantInt>(Call->getArgOperand(2)))
305 assert((ArgIdx == 0 || ArgIdx == 1) &&
306 "Invalid argument index for memcmp/bcmp");
308 dyn_cast<ConstantInt>(Call->getArgOperand(2)))
313 assert((ArgIdx == 0) &&
"Invalid argument index for memchr");
315 dyn_cast<ConstantInt>(Call->getArgOperand(2)))
319 case LibFunc_memccpy:
320 assert((ArgIdx == 0 || ArgIdx == 1) &&
321 "Invalid argument index for memccpy");
324 dyn_cast<ConstantInt>(Call->getArgOperand(3)))
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
This file provides utility analysis objects describing memory locations.
Module.h This file contains the declarations for the Module class.
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...