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

22

23#include

24

25namespace llvm {

26

39

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

67class LocationSize {

69 BeforeOrAfterPointer = ~uint64_t(0),

70 ScalableBit = uint64_t(1) << 62,

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

72 MapEmpty = BeforeOrAfterPointer - 2,

73 MapTombstone = BeforeOrAfterPointer - 3,

74 ImpreciseBit = uint64_t(1) << 63,

75

76

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

78 };

79

81

82 constexpr LocationSize(uint64_t Raw) : Value(Raw) {}

83 constexpr LocationSize(uint64_t Raw, bool Scalable)

84 : Value(Raw > MaxValue ? AfterPointer

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

86

87 static_assert(AfterPointer & ImpreciseBit,

88 "AfterPointer is imprecise by definition.");

89 static_assert(BeforeOrAfterPointer & ImpreciseBit,

90 "BeforeOrAfterPointer is imprecise by definition.");

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

92

93public:

94

96 return LocationSize(Value, false );

97 }

99 return LocationSize(Value.getKnownMinValue(), Value.isScalable());

100 }

101

103

108 return LocationSize(Value | ImpreciseBit);

109 }

111 if (Value.isScalable())

113 return upperBound(Value.getFixedValue());

114 }

115

116

117

119 return LocationSize(AfterPointer);

120 }

121

122

123

125 return LocationSize(BeforeOrAfterPointer);

126 }

127

128

130 return LocationSize(MapTombstone);

131 }

132 constexpr static LocationSize mapEmpty() {

133 return LocationSize(MapEmpty);

134 }

135

136

137

139 if (Other == *this)

140 return *this;

141

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

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

148

150 std::max(getValue().getFixedValue(), Other.getValue().getFixedValue()));

151 }

152

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

155 }

156 bool isScalable() const { return (Value & ScalableBit); }

157

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

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

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

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

163 }

164

165

166

167 bool isPrecise() const { return (Value & ImpreciseBit) == 0; }

168

169

173

174

176

178 return Value == Other.Value;

179 }

186

190

191

192

193

194

195

197

198

199

201};

202

204 Size.print(OS);

205 return OS;

206}

207

208

209

210

211

212

213

214

215

216

218public:

219

220

221

223

224

226

227

228

229

230

231

232

233

235

236

237

239

241

242

243

252 LLVM_ABI static std::optional

254

255

258

259

260

263 LLVM_ABI static std::optional

265

266

268 unsigned ArgIdx,

274

275

276

281

282

283

288

290

300

303 Copy.Ptr = NewPtr;

304 return Copy;

305 }

306

309 Copy.Size = NewSize;

310 return Copy;

311 }

318

324

328};

329

330

343

362}

363

364#endif

assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")

#define LLVM_UNLIKELY(EXPR)

This file defines DenseMapInfo traits for DenseMap.

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.

Definition MemoryLocation.h:67

bool hasValue() const

Definition MemoryLocation.h:153

static LocationSize precise(uint64_t Value)

Definition MemoryLocation.h:95

bool operator!=(uint64_t Other) const

Definition MemoryLocation.h:189

static constexpr LocationSize mapEmpty()

Definition MemoryLocation.h:132

static LocationSize upperBound(TypeSize Value)

Definition MemoryLocation.h:110

bool mayBeBeforePointer() const

Whether accesses before the base pointer are possible.

Definition MemoryLocation.h:175

bool operator==(const TypeSize &Other) const

Definition MemoryLocation.h:180

static constexpr LocationSize beforeOrAfterPointer()

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

Definition MemoryLocation.h:124

bool isScalable() const

Definition MemoryLocation.h:156

TypeSize getValue() const

Definition MemoryLocation.h:158

bool isZero() const

Definition MemoryLocation.h:170

LLVM_ABI void print(raw_ostream &OS) const

bool operator!=(const TypeSize &Other) const

Definition MemoryLocation.h:188

bool isPrecise() const

Definition MemoryLocation.h:167

bool operator!=(const LocationSize &Other) const

Definition MemoryLocation.h:187

static constexpr LocationSize afterPointer()

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

Definition MemoryLocation.h:118

uint64_t toRaw() const

Definition MemoryLocation.h:200

LocationSize unionWith(LocationSize Other) const

Definition MemoryLocation.h:138

bool operator==(uint64_t Other) const

Definition MemoryLocation.h:183

static LocationSize upperBound(uint64_t Value)

Definition MemoryLocation.h:102

static constexpr LocationSize mapTombstone()

Definition MemoryLocation.h:129

bool operator==(const LocationSize &Other) const

Definition MemoryLocation.h:177

static LocationSize precise(TypeSize Value)

Definition MemoryLocation.h:98

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

This class wraps the llvm.memcpy/memmove intrinsics.

Representation for a specific memory location.

Definition MemoryLocation.h:217

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

Definition MemoryLocation.h:294

@ UnknownSize

Definition MemoryLocation.h:222

MemoryLocation getWithNewSize(LocationSize NewSize) const

Definition MemoryLocation.h:307

MemoryLocation getWithoutAATags() const

Definition MemoryLocation.h:319

static LLVM_ABI 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)

Definition MemoryLocation.h:270

static LLVM_ABI MemoryLocation getForSource(const MemTransferInst *MTI)

Return a location representing the source of a memory transfer.

void print(raw_ostream &OS) const

Definition MemoryLocation.h:240

LocationSize Size

The maximum size of the location, in address-units, or UnknownSize if the size is not known.

Definition MemoryLocation.h:234

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

Definition MemoryLocation.h:285

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

Definition MemoryLocation.h:277

static MemoryLocation get(const Instruction *Inst)

Definition MemoryLocation.h:249

MemoryLocation getWithNewSize(uint64_t NewSize) const

Definition MemoryLocation.h:312

MemoryLocation getWithNewPtr(const Value *NewPtr) const

Definition MemoryLocation.h:301

MemoryLocation getWithNewSize(TypeSize NewSize) const

Definition MemoryLocation.h:315

AAMDNodes AATags

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

Definition MemoryLocation.h:238

const Value * Ptr

The address of the start of the location.

Definition MemoryLocation.h:225

MemoryLocation()

Definition MemoryLocation.h:289

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

Definition MemoryLocation.h:291

static LLVM_ABI MemoryLocation getForDest(const MemIntrinsic *MI)

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

bool operator==(const MemoryLocation &Other) const

Definition MemoryLocation.h:325

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

Definition MemoryLocation.h:297

static LLVM_ABI std::optional< MemoryLocation > getOrNone(const Instruction *Inst)

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

FunctionAddr VTableAddr Value

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()

Definition MemoryLocation.h:333

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

Definition MemoryLocation.h:339

static unsigned getHashValue(const LocationSize &Val)

Definition MemoryLocation.h:336

static LocationSize getEmptyKey()

Definition MemoryLocation.h:332

static MemoryLocation getTombstoneKey()

Definition MemoryLocation.h:349

static MemoryLocation getEmptyKey()

Definition MemoryLocation.h:345

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

Definition MemoryLocation.h:358

static unsigned getHashValue(const MemoryLocation &Val)

Definition MemoryLocation.h:353

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