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

1

2

3

4

5

6

7

8

9

10

11

12

13

14#ifndef LLVM_ANALYSIS_MEMORYBUILTINS_H

15#define LLVM_ANALYSIS_MEMORYBUILTINS_H

16

25#include

26#include

27#include

28

29namespace llvm {

30

52

53

54

55

60

61

62

64

65

66

69

70

71

73

74

75

77

78

80

81

82

83

84

85

87

88

91

92

93

94

95

96

97

98

99

100

101

102

103

104

106

107

108

109

110

113

114

115

116

117

118

122 return V;

123 });

124

125

126

127

131

132

133

134

135LLVM_ABI std::optional

137

138

139

140

141

142

144

146

147

149

150

152

153

155

157 };

158

159

161

162

164

165

166

168

170};

171

172

173

174

175

176

177

178

179

183

184

185

186

188 const DataLayout &DL,

189 const TargetLibraryInfo *TLI,

190 ObjectSizeOpts Opts = {});

191

192

193

194

195

199 bool MustSucceed);

204

205

206

207

209public:

212

216

221

226 return !(*this == RHS);

227 }

228};

229

230

231

236

237 static bool known(const APInt &V) { return V.getBitWidth() > 1; }

238};

239

240

241

242

243

244

245

265

266

267

269 : public InstVisitor<ObjectSizeOffsetVisitor, OffsetSpan> {

273 unsigned IntTyBits;

276 unsigned InstructionsVisited;

277

279

281

282public:

287

289

290

291

306

307private:

312 unsigned &ScannedInstCount);

316 bool CheckedZextOrTrunc(APInt &I);

317};

318

319

320

326

327 static bool known(Value *V) { return V != nullptr; }

328};

329

330

331

333 : public SizeOffsetType<WeakTrackingVH, SizeOffsetWeakTrackingVH> {

339

341};

342

343

344

346 : public InstVisitor<ObjectSizeOffsetEvaluator, SizeOffsetValue> {

351

355 BuilderTy Builder;

358 CacheMapTy CacheMap;

359 PtrSetTy SeenVals;

362

364

365public:

370

372

374

375

386};

387

388}

389

390#endif

This file implements a class to represent arbitrary precision integral constant values and operations...

MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL

static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")

SmallPtrSet< const BasicBlock *, 8 > VisitedBlocks

This file defines the DenseMap class.

This file defines the SmallPtrSet class.

Class for arbitrary precision integers.

an instruction to allocate memory on the stack

This class represents an incoming formal argument to a Function.

LLVM Basic Block Representation.

InstListType::iterator iterator

Instruction iterators...

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

A constant pointer value that points to null.

This is an important base class in LLVM.

A parsed version of the target data layout string in and methods for querying it.

This provides a uniform API for creating instructions and inserting them into a basic block: either a...

Base class for instruction visitors.

This class represents a cast from an integer to a pointer.

Class to represent integer types.

A wrapper class for inspecting calls to intrinsic functions.

This is an important class for using LLVM in a threaded context.

An instruction for reading from memory.

LLVM_ABI SizeOffsetValue visitExtractValueInst(ExtractValueInst &I)

LLVM_ABI SizeOffsetValue visitExtractElementInst(ExtractElementInst &I)

LLVM_ABI SizeOffsetValue compute(Value *V)

LLVM_ABI SizeOffsetValue visitInstruction(Instruction &I)

LLVM_ABI ObjectSizeOffsetEvaluator(const DataLayout &DL, const TargetLibraryInfo *TLI, LLVMContext &Context, ObjectSizeOpts EvalOpts={})

LLVM_ABI SizeOffsetValue visitLoadInst(LoadInst &I)

LLVM_ABI SizeOffsetValue visitGEPOperator(GEPOperator &GEP)

LLVM_ABI SizeOffsetValue visitIntToPtrInst(IntToPtrInst &)

LLVM_ABI SizeOffsetValue visitPHINode(PHINode &PHI)

LLVM_ABI SizeOffsetValue visitCallBase(CallBase &CB)

LLVM_ABI SizeOffsetValue visitSelectInst(SelectInst &I)

LLVM_ABI SizeOffsetValue visitAllocaInst(AllocaInst &I)

static SizeOffsetValue unknown()

Definition MemoryBuiltins.h:371

LLVM_ABI OffsetSpan visitSelectInst(SelectInst &I)

LLVM_ABI OffsetSpan visitExtractValueInst(ExtractValueInst &I)

LLVM_ABI OffsetSpan visitConstantPointerNull(ConstantPointerNull &)

LLVM_ABI OffsetSpan visitExtractElementInst(ExtractElementInst &I)

LLVM_ABI OffsetSpan visitGlobalVariable(GlobalVariable &GV)

LLVM_ABI OffsetSpan visitCallBase(CallBase &CB)

LLVM_ABI OffsetSpan visitIntToPtrInst(IntToPtrInst &)

LLVM_ABI OffsetSpan visitAllocaInst(AllocaInst &I)

LLVM_ABI ObjectSizeOffsetVisitor(const DataLayout &DL, const TargetLibraryInfo *TLI, LLVMContext &Context, ObjectSizeOpts Options={})

LLVM_ABI OffsetSpan visitLoadInst(LoadInst &I)

LLVM_ABI OffsetSpan visitPHINode(PHINode &)

LLVM_ABI OffsetSpan visitGlobalAlias(GlobalAlias &GA)

LLVM_ABI OffsetSpan visitInstruction(Instruction &I)

LLVM_ABI SizeOffsetAPInt compute(Value *V)

LLVM_ABI OffsetSpan visitUndefValue(UndefValue &)

LLVM_ABI OffsetSpan visitArgument(Argument &A)

This class represents the LLVM 'select' instruction.

SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.

This class consists of common code factored out of the SmallVector class to reduce code duplication b...

Provides information about what library functions are available for the current target.

The instances of the Type class are immutable: once they are created, they are never changed.

'undef' values are things that do not have specified contents.

LLVM Value Representation.

Value handle that is nullable, but tries to track the Value.

An efficient, type-erasing, non-owning reference to a callable.

Abstract Attribute helper functions.

This is an optimization pass for GlobalISel generic memory operations.

LLVM_ABI Constant * getInitialValueOfAllocation(const Value *V, const TargetLibraryInfo *TLI, Type *Ty)

If this is a call to an allocation function that initializes memory to a fixed value,...

LLVM_ABI bool isRemovableAlloc(const CallBase *V, const TargetLibraryInfo *TLI)

Return true if this is a call to an allocation function that does not have side effects that we are r...

LLVM_ABI std::optional< StringRef > getAllocationFamily(const Value *I, const TargetLibraryInfo *TLI)

If a function is part of an allocation family (e.g.

LLVM_ABI Value * lowerObjectSizeCall(IntrinsicInst *ObjectSize, const DataLayout &DL, const TargetLibraryInfo *TLI, bool MustSucceed)

Try to turn a call to @llvm.objectsize into an integer value of the given Type.

LLVM_ABI Value * getAllocAlignment(const CallBase *V, const TargetLibraryInfo *TLI)

Gets the alignment argument for an aligned_alloc-like function, using either built-in knowledge based...

LLVM_ABI bool isLibFreeFunction(const Function *F, const LibFunc TLIFn)

isLibFreeFunction - Returns true if the function is a builtin free()

LLVM_ABI Value * getReallocatedOperand(const CallBase *CB)

If this is a call to a realloc function, return the reallocated operand.

LLVM_ABI std::optional< TypeSize > getBaseObjectSize(const Value *Ptr, const DataLayout &DL, const TargetLibraryInfo *TLI, ObjectSizeOpts Opts={})

Like getObjectSize(), but only returns the size of base objects (like allocas, global variables and a...

LLVM_ABI bool isAllocLikeFn(const Value *V, const TargetLibraryInfo *TLI)

Tests if a value is a call or invoke to a library function that allocates memory (either malloc,...

LLVM_ABI bool getObjectSize(const Value *Ptr, uint64_t &Size, const DataLayout &DL, const TargetLibraryInfo *TLI, ObjectSizeOpts Opts={})

Compute the size of the object pointed by Ptr.

LLVM_ABI bool isMallocOrCallocLikeFn(const Value *V, const TargetLibraryInfo *TLI)

Tests if a value is a call or invoke to a library function that allocates memory similar to malloc or...

LLVM_ABI bool isReallocLikeFn(const Function *F)

Tests if a function is a call or invoke to a library function that reallocates memory (e....

LLVM_ABI Value * getFreedOperand(const CallBase *CB, const TargetLibraryInfo *TLI)

If this if a call to a free function, return the freed operand.

OutputIt move(R &&Range, OutputIt Out)

Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.

LLVM_ABI bool isAllocationFn(const Value *V, const TargetLibraryInfo *TLI)

Tests if a value is a call or invoke to a library function that allocates or reallocates memory (eith...

LLVM_ABI std::optional< APInt > getAllocSize(const CallBase *CB, const TargetLibraryInfo *TLI, function_ref< const Value *(const Value *)> Mapper=[](const Value *V) { return V;})

Return the size of the requested allocation.

LLVM_ABI bool isNewLikeFn(const Value *V, const TargetLibraryInfo *TLI)

Tests if a value is a call or invoke to a library function that allocates memory via new.

Implement std::hash so that hash_code can be used in STL containers.

This struct is a compact representation of a valid (non-zero power of two) alignment.

This struct is a compact representation of a valid (power of two) or undefined (0) alignment.

Various options to control the behavior of getObjectSize.

Definition MemoryBuiltins.h:143

bool NullIsUnknownSize

If this is true, null pointers in address space 0 will be treated as though they can't be evaluated.

Definition MemoryBuiltins.h:167

Mode EvalMode

How we want to evaluate this object's size.

Definition MemoryBuiltins.h:160

AAResults * AA

If set, used for more accurate evaluation.

Definition MemoryBuiltins.h:169

bool RoundToAlign

Whether to round the result up to the alignment of allocas, byval arguments, and global variables.

Definition MemoryBuiltins.h:163

Mode

Controls how we handle conditional statements with unknown conditions.

Definition MemoryBuiltins.h:145

@ ExactUnderlyingSizeAndOffset

All branches must be known and have the same underlying size and offset to be merged.

Definition MemoryBuiltins.h:151

@ Max

Same as Min, except we pick the maximum size of all of the branches.

Definition MemoryBuiltins.h:156

@ Min

Evaluate all branches of an unknown condition.

Definition MemoryBuiltins.h:154

@ ExactSizeFromOffset

All branches must be known and have the same size, starting from the offset, to be merged.

Definition MemoryBuiltins.h:148

OffsetSpan - Used internally by ObjectSizeOffsetVisitor.

Definition MemoryBuiltins.h:246

OffsetSpan()=default

Number of allocated bytes after this point.

bool knownBefore() const

Definition MemoryBuiltins.h:253

APInt After

Number of allocated bytes before this point.

Definition MemoryBuiltins.h:248

bool anyKnown() const

Definition MemoryBuiltins.h:255

bool knownAfter() const

Definition MemoryBuiltins.h:254

static bool known(const APInt &V)

Definition MemoryBuiltins.h:263

bool operator!=(const OffsetSpan &RHS) const

Definition MemoryBuiltins.h:261

bool operator==(const OffsetSpan &RHS) const

Definition MemoryBuiltins.h:258

OffsetSpan(APInt Before, APInt After)

Definition MemoryBuiltins.h:251

bool bothKnown() const

Definition MemoryBuiltins.h:256

APInt Before

Definition MemoryBuiltins.h:247

SizeOffsetAPInt - Used by ObjectSizeOffsetVisitor, which works with APInts.

Definition MemoryBuiltins.h:232

SizeOffsetAPInt()=default

static bool known(const APInt &V)

Definition MemoryBuiltins.h:237

SizeOffsetAPInt(APInt Size, APInt Offset)

Definition MemoryBuiltins.h:234

T Size

Definition MemoryBuiltins.h:210

bool operator!=(const SizeOffsetType< T, C > &RHS) const

Definition MemoryBuiltins.h:225

bool operator==(const SizeOffsetType< T, C > &RHS) const

Definition MemoryBuiltins.h:222

SizeOffsetType(T Size, T Offset)

Definition MemoryBuiltins.h:214

bool knownOffset() const

Definition MemoryBuiltins.h:218

T Offset

Definition MemoryBuiltins.h:211

bool anyKnown() const

Definition MemoryBuiltins.h:219

bool knownSize() const

Definition MemoryBuiltins.h:217

bool bothKnown() const

Definition MemoryBuiltins.h:220

Definition MemoryBuiltins.h:322

SizeOffsetValue(Value *Size, Value *Offset)

Definition MemoryBuiltins.h:324

SizeOffsetValue()

Definition MemoryBuiltins.h:323

static bool known(Value *V)

Definition MemoryBuiltins.h:327

SizeOffsetWeakTrackingVH - Used by ObjectSizeOffsetEvaluator in a DenseMap.

Definition MemoryBuiltins.h:333

SizeOffsetWeakTrackingVH()

Definition MemoryBuiltins.h:334

SizeOffsetWeakTrackingVH(const SizeOffsetValue &SOV)

Definition MemoryBuiltins.h:337

static bool known(WeakTrackingVH V)

Definition MemoryBuiltins.h:340

SizeOffsetWeakTrackingVH(Value *Size, Value *Offset)

Definition MemoryBuiltins.h:335