LLVM: include/llvm/Analysis/MemoryLocation.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15#ifndef LLVM_ANALYSIS_MEMORYLOCATION_H

16#define LLVM_ANALYSIS_MEMORYLOCATION_H

17

21

22#include

23

24namespace llvm {

25

26class CallBase;

27class Instruction;

28class LoadInst;

29class StoreInst;

30class MemTransferInst;

31class MemIntrinsic;

32class AtomicCmpXchgInst;

33class AtomicMemTransferInst;

34class AtomicMemIntrinsic;

35class AtomicRMWInst;

36class AnyMemTransferInst;

37class AnyMemIntrinsic;

38class TargetLibraryInfo;

39class VAArgInst;

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

70 BeforeOrAfterPointer = ~uint64_t(0),

71 ScalableBit = uint64_t(1) << 62,

72 AfterPointer = (BeforeOrAfterPointer - 1) & ~ScalableBit,

73 MapEmpty = BeforeOrAfterPointer - 2,

74 MapTombstone = BeforeOrAfterPointer - 3,

75 ImpreciseBit = uint64_t(1) << 63,

76

77

78 MaxValue = (MapTombstone - 1) & ~(ImpreciseBit | ScalableBit),

79 };

80

82

83

84

85 enum DirectConstruction { Direct };

86

89 : Value(Raw > MaxValue ? AfterPointer

90 : Raw | (Scalable ? ScalableBit : uint64_t(0))) {}

91

92 static_assert(AfterPointer & ImpreciseBit,

93 "AfterPointer is imprecise by definition.");

94 static_assert(BeforeOrAfterPointer & ImpreciseBit,

95 "BeforeOrAfterPointer is imprecise by definition.");

96 static_assert(~(MaxValue & ScalableBit), "Max value don't have bit 62 set");

97

98public:

99

100

101

102

103

104

106 : Value(Raw > MaxValue ? AfterPointer : Raw) {}

107

110 }

113 }

114

116

122 }

124 if (Value.isScalable())

127 }

128

129

130

133 }

134

135

136

138 return LocationSize(BeforeOrAfterPointer, Direct);

139 }

140

141

144 }

147 }

148

149

150

152 if (Other == *this)

153 return *this;

154

155 if (Value == BeforeOrAfterPointer || Other.Value == BeforeOrAfterPointer)

157 if (Value == AfterPointer || Other.Value == AfterPointer)

161

163 }

164

166 return Value != AfterPointer && Value != BeforeOrAfterPointer;

167 }

169

171 assert(hasValue() && "Getting value from an unknown LocationSize!");

172 assert((Value & ~(ImpreciseBit | ScalableBit)) < MaxValue &&

173 "Scalable bit of value should be masked");

174 return {Value & ~(ImpreciseBit | ScalableBit), isScalable()};

175 }

176

177

178

180

181

184 }

185

186

188

191 }

192

195 }

196

198

200

201

202

203

204

205

207

208

209

211};

212

215 return OS;

216}

217

218

219

220

221

222

223

224

225

226

228public:

229

230

231

233

234

236

237

238

239

240

241

242

243

245

246

247

249

251

252

253

261 }

263

264

268

269

270

276

277

283 }

284

285

286

290 }

291

292

293

297 }

298

300

304

307 Copy.Ptr = NewPtr;

308 return Copy;

309 }

310

313 Copy.Size = NewSize;

314 return Copy;

315 }

316

320 return Copy;

321 }

322

325 }

326};

327

328

333 }

336 }

339 }

340};

341

346 }

350 }

355 }

358 }

359};

360}

361

362#endif

#define LLVM_UNLIKELY(EXPR)

This file defines DenseMapInfo traits for DenseMap.

assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())

An instruction that atomically checks whether a specified value is in a memory location,...

an instruction that atomically reads a memory location, combines it with another value,...

Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...

An instruction for reading from memory.

static LocationSize precise(uint64_t Value)

static constexpr LocationSize mapEmpty()

static LocationSize upperBound(TypeSize Value)

bool mayBeBeforePointer() const

Whether accesses before the base pointer are possible.

bool operator==(const TypeSize &Other) const

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

bool operator!=(const TypeSize &Other) const

bool operator!=(const LocationSize &Other) const

static constexpr LocationSize afterPointer()

Any location after the base pointer (but still within the underlying object).

LocationSize unionWith(LocationSize Other) const

static LocationSize upperBound(uint64_t Value)

constexpr LocationSize(uint64_t Raw)

static constexpr LocationSize mapTombstone()

bool operator==(const LocationSize &Other) const

static LocationSize precise(TypeSize Value)

This is the common base class for memset/memcpy/memmove.

This class wraps the llvm.memcpy/memmove intrinsics.

Representation for a specific memory location.

MemoryLocation getWithNewSize(LocationSize NewSize) const

MemoryLocation getWithoutAATags() const

static MemoryLocation get(const LoadInst *LI)

Return a location with information about the memory reference by the given instruction.

static MemoryLocation getForArgument(const CallBase *Call, unsigned ArgIdx, const TargetLibraryInfo &TLI)

static MemoryLocation getForSource(const MemTransferInst *MTI)

Return a location representing the source of a memory transfer.

void print(raw_ostream &OS) const

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...

static MemoryLocation get(const Instruction *Inst)

MemoryLocation getWithNewPtr(const Value *NewPtr) const

AAMDNodes AATags

The metadata nodes which describes the aliasing of the location (each member is null if that kind of ...

const Value * Ptr

The address of the start of the location.

MemoryLocation(const Value *Ptr, LocationSize Size, const AAMDNodes &AATags=AAMDNodes())

static MemoryLocation getForDest(const MemIntrinsic *MI)

Return a location representing the destination of a memory set or transfer.

bool operator==(const MemoryLocation &Other) const

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.

This class represents the va_arg llvm instruction, which returns an argument of the specified type gi...

LLVM Value Representation.

constexpr ScalarTy getKnownMinValue() const

Returns the minimum value this quantity can represent.

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.

raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)

A collection of metadata nodes that might be associated with a memory access used by the alias-analys...

static LocationSize getTombstoneKey()

static bool isEqual(const LocationSize &LHS, const LocationSize &RHS)

static unsigned getHashValue(const LocationSize &Val)

static LocationSize getEmptyKey()

static MemoryLocation getTombstoneKey()

static MemoryLocation getEmptyKey()

static bool isEqual(const MemoryLocation &LHS, const MemoryLocation &RHS)

static unsigned getHashValue(const MemoryLocation &Val)

An information struct used to provide DenseMap with the various necessary components for a given valu...