15 #ifndef LLVM_ANALYSIS_MEMORYLOCATION_H 16 #define LLVM_ANALYSIS_MEMORYLOCATION_H 27 class MemTransferInst;
29 class AtomicMemTransferInst;
30 class AtomicMemIntrinsic;
31 class AnyMemTransferInst;
32 class AnyMemIntrinsic;
33 class TargetLibraryInfo;
62 Unknown = ~uint64_t(0),
63 ImpreciseBit = uint64_t(1) << 63,
64 MapEmpty = Unknown - 1,
65 MapTombstone = Unknown - 2,
68 MaxValue = (MapTombstone - 1) & ~ImpreciseBit,
75 enum DirectConstruction { Direct };
77 constexpr
LocationSize(uint64_t Raw, DirectConstruction): Value(Raw) {}
79 static_assert(Unknown & ImpreciseBit,
"Unknown is imprecise by definition.");
88 : Value(Raw > MaxValue ? Unknown : Raw) {}
90 static LocationSize
precise(uint64_t Value) {
return LocationSize(Value); }
98 return LocationSize(Value | ImpreciseBit, Direct);
102 return LocationSize(Unknown, Direct);
107 return LocationSize(MapTombstone, Direct);
110 return LocationSize(MapEmpty, Direct);
127 assert(
hasValue() &&
"Getting value from an unknown LocationSize!");
128 return Value & ~ImpreciseBit;
134 return (Value & ImpreciseBit) == 0;
141 return Value == Other.Value;
145 return !(*
this ==
Other);
157 uint64_t
toRaw()
const {
return Value; }
179 enum : uint64_t { UnknownSize = ~UINT64_C(0) };
210 return get(cast<LoadInst>(Inst));
212 return get(cast<StoreInst>(Inst));
213 case Instruction::VAArg:
214 return get(cast<VAArgInst>(Inst));
215 case Instruction::AtomicCmpXchg:
216 return get(cast<AtomicCmpXchgInst>(Inst));
217 case Instruction::AtomicRMW:
218 return get(cast<AtomicRMWInst>(Inst));
240 return getForArgument(Call, ArgIdx, &TLI);
246 : Ptr(Ptr), Size(Size), AATags(AATags) {}
267 return Ptr == Other.
Ptr && Size == Other.
Size && AATags == Other.
AATags;
bool operator==(const LocationSize &Other) const
This class represents lattice values for constants.
static bool isEqual(const LocationSize &LHS, const LocationSize &RHS)
#define LLVM_UNLIKELY(EXPR)
An instruction that atomically checks whether a specified value is in a memory location, and, if it is, stores a new value there.
MemoryLocation getWithNewPtr(const Value *NewPtr) const
static constexpr LocationSize unknown()
static LocationSize precise(uint64_t Value)
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
An instruction for reading from memory.
an instruction that atomically reads a memory location, combines it with another value, and then stores the result back.
static Optional< MemoryLocation > getOrNone(const Instruction *Inst)
static LocationSize getEmptyKey()
static constexpr LocationSize mapTombstone()
bool operator!=(const LocationSize &Other) const
static LocationSize getTombstoneKey()
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
An instruction for storing to memory.
uint64_t getValue() const
MemoryLocation getWithoutAATags() const
MemoryLocation getWithNewSize(LocationSize NewSize) const
LocationSize unionWith(LocationSize Other) const
static constexpr LocationSize mapEmpty()
LocationSize Size
The maximum size of the location, in address-units, or UnknownSize if the size is not known...
bool operator==(const MemoryLocation &Other) const
MemoryLocation(const Value *Ptr=nullptr, LocationSize Size=LocationSize::unknown(), const AAMDNodes &AATags=AAMDNodes())
This class represents the va_arg llvm instruction, which returns an argument of the specified type gi...
constexpr LocationSize(uint64_t Raw)
const Value * Ptr
The address of the start of the location.
Representation for a specific memory location.
This is the common base class for memset/memcpy/memmove.
static unsigned getHashValue(const LocationSize &Val)
Align max(MaybeAlign Lhs, Align Rhs)
Provides information about what library functions are available for the current target.
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
static bool isEqual(const MemoryLocation &LHS, const MemoryLocation &RHS)
void print(raw_ostream &OS) const
This class wraps the llvm.memcpy/memmove intrinsics.
AAMDNodes AATags
The metadata nodes which describes the aliasing of the location (each member is null if that kind of ...
static LocationSize upperBound(uint64_t Value)
raw_ostream & operator<<(raw_ostream &OS, const APInt &I)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
This class implements an extremely fast bulk output stream that can only output to a stream...
static MemoryLocation getForArgument(const CallBase *Call, unsigned ArgIdx, const TargetLibraryInfo &TLI)
static MemoryLocation getTombstoneKey()
static MemoryLocation getEmptyKey()
static unsigned getHashValue(const MemoryLocation &Val)