LLVM  16.0.0git
MemoryBuiltins.h
Go to the documentation of this file.
1 //==- llvm/Analysis/MemoryBuiltins.h - Calls to memory builtins --*- C++ -*-==//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This family of functions identifies calls to builtin functions that allocate
10 // or free memory.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_ANALYSIS_MEMORYBUILTINS_H
15 #define LLVM_ANALYSIS_MEMORYBUILTINS_H
16 
17 #include "llvm/ADT/APInt.h"
18 #include "llvm/ADT/DenseMap.h"
19 #include "llvm/ADT/SmallPtrSet.h"
22 #include "llvm/IR/IRBuilder.h"
23 #include "llvm/IR/InstVisitor.h"
24 #include "llvm/IR/ValueHandle.h"
25 #include <cstdint>
26 #include <utility>
27 
28 namespace llvm {
29 
30 class AllocaInst;
31 class AAResults;
32 class Argument;
33 class ConstantPointerNull;
34 class DataLayout;
35 class ExtractElementInst;
36 class ExtractValueInst;
37 class GEPOperator;
38 class GlobalAlias;
39 class GlobalVariable;
40 class Instruction;
41 class IntegerType;
42 class IntrinsicInst;
43 class IntToPtrInst;
44 class LLVMContext;
45 class LoadInst;
46 class PHINode;
47 class SelectInst;
48 class Type;
49 class UndefValue;
50 class Value;
51 
52 /// Tests if a value is a call or invoke to a library function that
53 /// allocates or reallocates memory (either malloc, calloc, realloc, or strdup
54 /// like).
55 bool isAllocationFn(const Value *V, const TargetLibraryInfo *TLI);
56 bool isAllocationFn(const Value *V,
57  function_ref<const TargetLibraryInfo &(Function &)> GetTLI);
58 
59 /// Tests if a value is a call or invoke to a library function that
60 /// allocates memory via new.
61 bool isNewLikeFn(const Value *V, const TargetLibraryInfo *TLI);
62 
63 /// Tests if a value is a call or invoke to a library function that
64 /// allocates memory similar to malloc or calloc.
65 bool isMallocOrCallocLikeFn(const Value *V, const TargetLibraryInfo *TLI);
66 
67 /// Tests if a value is a call or invoke to a library function that
68 /// allocates memory (either malloc, calloc, or strdup like).
69 bool isAllocLikeFn(const Value *V, const TargetLibraryInfo *TLI);
70 
71 /// Tests if a function is a call or invoke to a library function that
72 /// reallocates memory (e.g., realloc).
73 bool isReallocLikeFn(const Function *F, const TargetLibraryInfo *TLI);
74 
75 /// If this is a call to a realloc function, return the reallocated operand.
76 Value *getReallocatedOperand(const CallBase *CB, const TargetLibraryInfo *TLI);
77 
78 //===----------------------------------------------------------------------===//
79 // free Call Utility Functions.
80 //
81 
82 /// isLibFreeFunction - Returns true if the function is a builtin free()
83 bool isLibFreeFunction(const Function *F, const LibFunc TLIFn);
84 
85 /// If this if a call to a free function, return the freed operand.
86 Value *getFreedOperand(const CallBase *CB, const TargetLibraryInfo *TLI);
87 
88 //===----------------------------------------------------------------------===//
89 // Properties of allocation functions
90 //
91 
92 /// Return true if this is a call to an allocation function that does not have
93 /// side effects that we are required to preserve beyond the effect of
94 /// allocating a new object.
95 /// Ex: If our allocation routine has a counter for the number of objects
96 /// allocated, and the program prints it on exit, can the value change due
97 /// to optimization? Answer is highly language dependent.
98 /// Note: *Removable* really does mean removable; it does not mean observable.
99 /// A language (e.g. C++) can allow removing allocations without allowing
100 /// insertion or speculative execution of allocation routines.
101 bool isRemovableAlloc(const CallBase *V, const TargetLibraryInfo *TLI);
102 
103 /// Gets the alignment argument for an aligned_alloc-like function, using either
104 /// built-in knowledge based on fuction names/signatures or allocalign
105 /// attributes. Note: the Value returned may not indicate a valid alignment, per
106 /// the definition of the allocalign attribute.
107 Value *getAllocAlignment(const CallBase *V, const TargetLibraryInfo *TLI);
108 
109 /// Return the size of the requested allocation. With a trivial mapper, this is
110 /// similar to calling getObjectSize(..., Exact), but without looking through
111 /// calls that return their argument. A mapper function can be used to replace
112 /// one Value* (operand to the allocation) with another. This is useful when
113 /// doing abstract interpretation.
114 Optional<APInt> getAllocSize(
115  const CallBase *CB, const TargetLibraryInfo *TLI,
116  function_ref<const Value *(const Value *)> Mapper = [](const Value *V) {
117  return V;
118  });
119 
120 /// If this is a call to an allocation function that initializes memory to a
121 /// fixed value, return said value in the requested type. Otherwise, return
122 /// nullptr.
124  const TargetLibraryInfo *TLI,
125  Type *Ty);
126 
127 /// If a function is part of an allocation family (e.g.
128 /// malloc/realloc/calloc/free), return the identifier for its family
129 /// of functions.
130 Optional<StringRef> getAllocationFamily(const Value *I,
131  const TargetLibraryInfo *TLI);
132 
133 //===----------------------------------------------------------------------===//
134 // Utility functions to compute size of objects.
135 //
136 
137 /// Various options to control the behavior of getObjectSize.
139  /// Controls how we handle conditional statements with unknown conditions.
140  enum class Mode : uint8_t {
141  /// All branches must be known and have the same size, starting from the
142  /// offset, to be merged.
144  /// All branches must be known and have the same underlying size and offset
145  /// to be merged.
147  /// Evaluate all branches of an unknown condition. If all evaluations
148  /// succeed, pick the minimum size.
149  Min,
150  /// Same as Min, except we pick the maximum size of all of the branches.
151  Max,
152  };
153 
154  /// How we want to evaluate this object's size.
156  /// Whether to round the result up to the alignment of allocas, byval
157  /// arguments, and global variables.
158  bool RoundToAlign = false;
159  /// If this is true, null pointers in address space 0 will be treated as
160  /// though they can't be evaluated. Otherwise, null is always considered to
161  /// point to a 0 byte region of memory.
162  bool NullIsUnknownSize = false;
163  /// If set, used for more accurate evaluation
164  AAResults *AA = nullptr;
165 };
166 
167 /// Compute the size of the object pointed by Ptr. Returns true and the
168 /// object size in Size if successful, and false otherwise. In this context, by
169 /// object we mean the region of memory starting at Ptr to the end of the
170 /// underlying object pointed to by Ptr.
171 ///
172 /// WARNING: The object size returned is the allocation size. This does not
173 /// imply dereferenceability at site of use since the object may be freeed in
174 /// between.
175 bool getObjectSize(const Value *Ptr, uint64_t &Size, const DataLayout &DL,
176  const TargetLibraryInfo *TLI, ObjectSizeOpts Opts = {});
177 
178 /// Try to turn a call to \@llvm.objectsize into an integer value of the given
179 /// Type. Returns null on failure. If MustSucceed is true, this function will
180 /// not return null, and may return conservative values governed by the second
181 /// argument of the call to objectsize.
182 Value *lowerObjectSizeCall(IntrinsicInst *ObjectSize, const DataLayout &DL,
183  const TargetLibraryInfo *TLI, bool MustSucceed);
184 Value *lowerObjectSizeCall(IntrinsicInst *ObjectSize, const DataLayout &DL,
185  const TargetLibraryInfo *TLI, AAResults *AA,
186  bool MustSucceed);
187 
188 using SizeOffsetType = std::pair<APInt, APInt>;
189 
190 /// Evaluate the size and offset of an object pointed to by a Value*
191 /// statically. Fails if size or offset are not known at compile time.
193  : public InstVisitor<ObjectSizeOffsetVisitor, SizeOffsetType> {
194  const DataLayout &DL;
195  const TargetLibraryInfo *TLI;
196  ObjectSizeOpts Options;
197  unsigned IntTyBits;
198  APInt Zero;
200 
201  APInt align(APInt Size, MaybeAlign Align);
202 
203  SizeOffsetType unknown() {
204  return std::make_pair(APInt(), APInt());
205  }
206 
207 public:
210 
212 
213  static bool knownSize(const SizeOffsetType &SizeOffset) {
214  return SizeOffset.first.getBitWidth() > 1;
215  }
216 
217  static bool knownOffset(const SizeOffsetType &SizeOffset) {
218  return SizeOffset.second.getBitWidth() > 1;
219  }
220 
221  static bool bothKnown(const SizeOffsetType &SizeOffset) {
222  return knownSize(SizeOffset) && knownOffset(SizeOffset);
223  }
224 
225  // These are "private", except they can't actually be made private. Only
226  // compute() should be used by external users.
241 
242 private:
243  SizeOffsetType findLoadSizeOffset(
246  unsigned &ScannedInstCount);
247  SizeOffsetType combineSizeOffset(SizeOffsetType LHS, SizeOffsetType RHS);
248  SizeOffsetType computeImpl(Value *V);
249  bool CheckedZextOrTrunc(APInt &I);
250 };
251 
252 using SizeOffsetEvalType = std::pair<Value *, Value *>;
253 
254 /// Evaluate the size and offset of an object pointed to by a Value*.
255 /// May create code to compute the result at run-time.
257  : public InstVisitor<ObjectSizeOffsetEvaluator, SizeOffsetEvalType> {
259  using WeakEvalType = std::pair<WeakTrackingVH, WeakTrackingVH>;
262 
263  const DataLayout &DL;
264  const TargetLibraryInfo *TLI;
265  LLVMContext &Context;
266  BuilderTy Builder;
267  IntegerType *IntTy;
268  Value *Zero;
269  CacheMapTy CacheMap;
270  PtrSetTy SeenVals;
271  ObjectSizeOpts EvalOpts;
272  SmallPtrSet<Instruction *, 8> InsertedInstructions;
273 
274  SizeOffsetEvalType compute_(Value *V);
275 
276 public:
278  return std::make_pair(nullptr, nullptr);
279  }
280 
282  LLVMContext &Context, ObjectSizeOpts EvalOpts = {});
283 
285 
286  bool knownSize(SizeOffsetEvalType SizeOffset) {
287  return SizeOffset.first;
288  }
289 
290  bool knownOffset(SizeOffsetEvalType SizeOffset) {
291  return SizeOffset.second;
292  }
293 
294  bool anyKnown(SizeOffsetEvalType SizeOffset) {
295  return knownSize(SizeOffset) || knownOffset(SizeOffset);
296  }
297 
298  bool bothKnown(SizeOffsetEvalType SizeOffset) {
299  return knownSize(SizeOffset) && knownOffset(SizeOffset);
300  }
301 
302  // The individual instruction visitors should be treated as private.
313 };
314 
315 } // end namespace llvm
316 
317 #endif // LLVM_ANALYSIS_MEMORYBUILTINS_H
llvm::isNewLikeFn
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.
Definition: MemoryBuiltins.cpp:308
llvm::ObjectSizeOffsetEvaluator::unknown
static SizeOffsetEvalType unknown()
Definition: MemoryBuiltins.h:277
llvm::SizeOffsetType
std::pair< APInt, APInt > SizeOffsetType
Definition: MemoryBuiltins.h:188
llvm::Argument
This class represents an incoming formal argument to a Function.
Definition: Argument.h:28
llvm::ObjectSizeOffsetVisitor::visitGlobalAlias
SizeOffsetType visitGlobalAlias(GlobalAlias &GA)
Definition: MemoryBuiltins.cpp:850
llvm::getReallocatedOperand
Value * getReallocatedOperand(const CallBase *CB, const TargetLibraryInfo *TLI)
If this is a call to a realloc function, return the reallocated operand.
Definition: MemoryBuiltins.cpp:350
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::DataLayout
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:113
llvm::BasicBlock::iterator
InstListType::iterator iterator
Instruction iterators...
Definition: BasicBlock.h:87
PHI
Rewrite undef for PHI
Definition: AMDGPURewriteUndefForPHI.cpp:101
llvm::ExtractElementInst
This instruction extracts a single (scalar) element from a VectorType value.
Definition: Instructions.h:1872
TargetFolder.h
llvm::ObjectSizeOffsetEvaluator::compute
SizeOffsetEvalType compute(Value *V)
Definition: MemoryBuiltins.cpp:1050
llvm::ObjectSizeOffsetVisitor::visitExtractValueInst
SizeOffsetType visitExtractValueInst(ExtractValueInst &I)
Definition: MemoryBuiltins.cpp:845
llvm::IRBuilder< TargetFolder, IRBuilderCallbackInserter >
llvm::GlobalVariable
Definition: GlobalVariable.h:39
llvm::ObjectSizeOffsetEvaluator::visitSelectInst
SizeOffsetEvalType visitSelectInst(SelectInst &I)
Definition: MemoryBuiltins.cpp:1245
llvm::ObjectSizeOffsetEvaluator::visitGEPOperator
SizeOffsetEvalType visitGEPOperator(GEPOperator &GEP)
Definition: MemoryBuiltins.cpp:1184
llvm::SmallDenseMap
Definition: DenseMap.h:880
llvm::GlobalAlias
Definition: GlobalAlias.h:28
APInt.h
DenseMap.h
llvm::ObjectSizeOpts::NullIsUnknownSize
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:162
llvm::ObjectSizeOffsetEvaluator::visitCallBase
SizeOffsetEvalType visitCallBase(CallBase &CB)
Definition: MemoryBuiltins.cpp:1151
llvm::SmallPtrSet
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
Definition: SmallPtrSet.h:450
llvm::ObjectSizeOpts::RoundToAlign
bool RoundToAlign
Whether to round the result up to the alignment of allocas, byval arguments, and global variables.
Definition: MemoryBuiltins.h:158
RHS
Value * RHS
Definition: X86PartialReduction.cpp:76
llvm::logicalview::LVAttributeKind::Argument
@ Argument
llvm::ObjectSizeOpts::Mode::ExactUnderlyingSizeAndOffset
@ ExactUnderlyingSizeAndOffset
All branches must be known and have the same underlying size and offset to be merged.
llvm::ObjectSizeOffsetEvaluator::visitLoadInst
SizeOffsetEvalType visitLoadInst(LoadInst &I)
Definition: MemoryBuiltins.cpp:1199
F
#define F(x, y, z)
Definition: MD5.cpp:55
llvm::BasicBlock
LLVM Basic Block Representation.
Definition: BasicBlock.h:55
Context
LLVMContext & Context
Definition: NVVMIntrRange.cpp:66
llvm::ObjectSizeOffsetEvaluator::visitIntToPtrInst
SizeOffsetEvalType visitIntToPtrInst(IntToPtrInst &)
Definition: MemoryBuiltins.cpp:1194
llvm::isAllocationFn
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...
Definition: MemoryBuiltins.cpp:295
llvm::ConstantPointerNull
A constant pointer value that points to null.
Definition: Constants.h:535
LHS
Value * LHS
Definition: X86PartialReduction.cpp:75
llvm::ObjectSizeOffsetVisitor::bothKnown
static bool bothKnown(const SizeOffsetType &SizeOffset)
Definition: MemoryBuiltins.h:221
llvm::ISD::Constant
@ Constant
Definition: ISDOpcodes.h:76
llvm::AAResults
Definition: AliasAnalysis.h:294
llvm::ObjectSizeOffsetEvaluator::knownSize
bool knownSize(SizeOffsetEvalType SizeOffset)
Definition: MemoryBuiltins.h:286
llvm::LibFunc
LibFunc
Definition: TargetLibraryInfo.h:36
llvm::ObjectSizeOffsetVisitor::visitIntToPtrInst
SizeOffsetType visitIntToPtrInst(IntToPtrInst &)
Definition: MemoryBuiltins.cpp:864
llvm::ObjectSizeOffsetEvaluator::ObjectSizeOffsetEvaluator
ObjectSizeOffsetEvaluator(const DataLayout &DL, const TargetLibraryInfo *TLI, LLVMContext &Context, ObjectSizeOpts EvalOpts={})
Definition: MemoryBuiltins.cpp:1038
TargetLibraryInfo.h
llvm::MaybeAlign
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
Definition: Alignment.h:117
llvm::IntegerType
Class to represent integer types.
Definition: DerivedTypes.h:40
llvm::ObjectSizeOffsetVisitor::visitGlobalVariable
SizeOffsetType visitGlobalVariable(GlobalVariable &GV)
Definition: MemoryBuiltins.cpp:856
llvm::Instruction
Definition: Instruction.h:42
llvm::ObjectSizeOffsetVisitor::visitAllocaInst
SizeOffsetType visitAllocaInst(AllocaInst &I)
Definition: MemoryBuiltins.cpp:785
llvm::ObjectSizeOffsetEvaluator::visitExtractElementInst
SizeOffsetEvalType visitExtractElementInst(ExtractElementInst &I)
Definition: MemoryBuiltins.cpp:1174
llvm::ObjectSizeOpts::Mode::ExactSizeFromOffset
@ ExactSizeFromOffset
All branches must be known and have the same size, starting from the offset, to be merged.
Options
const char LLVMTargetMachineRef LLVMPassBuilderOptionsRef Options
Definition: PassBuilderBindings.cpp:48
llvm::ObjectSizeOffsetEvaluator
Evaluate the size and offset of an object pointed to by a Value*.
Definition: MemoryBuiltins.h:256
SmallPtrSet.h
llvm::ObjectSizeOffsetEvaluator::visitPHINode
SizeOffsetEvalType visitPHINode(PHINode &PHI)
Definition: MemoryBuiltins.cpp:1203
llvm::Align
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
llvm::getObjectSize
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.
Definition: MemoryBuiltins.cpp:614
llvm::getFreedOperand
Value * getFreedOperand(const CallBase *CB, const TargetLibraryInfo *TLI)
If this if a call to a free function, return the freed operand.
Definition: MemoryBuiltins.cpp:582
llvm::isReallocLikeFn
bool isReallocLikeFn(const Function *F, const TargetLibraryInfo *TLI)
Tests if a function is a call or invoke to a library function that reallocates memory (e....
Definition: MemoryBuiltins.cpp:345
llvm::getInitialValueOfAllocation
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,...
Definition: MemoryBuiltins.cpp:459
uint64_t
llvm::LLVMContext
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:67
llvm::DenseMap< const Value *, WeakEvalType >
llvm::ObjectSizeOffsetVisitor::visitUndefValue
SizeOffsetType visitUndefValue(UndefValue &)
Definition: MemoryBuiltins.cpp:1028
I
#define I(x, y, z)
Definition: MD5.cpp:58
llvm::UndefValue
'undef' values are things that do not have specified contents.
Definition: Constants.h:1356
llvm::ObjectSizeOffsetVisitor
Evaluate the size and offset of an object pointed to by a Value* statically.
Definition: MemoryBuiltins.h:192
llvm::lowerObjectSizeCall
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.
Definition: MemoryBuiltins.cpp:625
llvm::ObjectSizeOffsetVisitor::visitSelectInst
SizeOffsetType visitSelectInst(SelectInst &I)
Definition: MemoryBuiltins.cpp:1023
llvm::isAllocLikeFn
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,...
Definition: MemoryBuiltins.cpp:338
TemplateParamKind::Type
@ Type
IRBuilder.h
llvm::ObjectSizeOpts::Mode::Min
@ Min
Evaluate all branches of an unknown condition.
Ptr
@ Ptr
Definition: TargetLibraryInfo.cpp:60
llvm::SelectInst
This class represents the LLVM 'select' instruction.
Definition: Instructions.h:1737
llvm::GEPOperator
Definition: Operator.h:375
llvm::APInt
Class for arbitrary precision integers.
Definition: APInt.h:75
llvm::ObjectSizeOffsetEvaluator::visitAllocaInst
SizeOffsetEvalType visitAllocaInst(AllocaInst &I)
Definition: MemoryBuiltins.cpp:1131
llvm::ObjectSizeOpts::AA
AAResults * AA
If set, used for more accurate evaluation.
Definition: MemoryBuiltins.h:164
InstVisitor.h
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition: AArch64SLSHardening.cpp:76
llvm::InstVisitor
Base class for instruction visitors.
Definition: InstVisitor.h:78
llvm::ObjectSizeOpts
Various options to control the behavior of getObjectSize.
Definition: MemoryBuiltins.h:138
llvm::LoadInst
An instruction for reading from memory.
Definition: Instructions.h:174
ValueHandle.h
llvm::ObjectSizeOpts::Mode::Max
@ Max
Same as Min, except we pick the maximum size of all of the branches.
llvm::ObjectSizeOffsetVisitor::visitLoadInst
SizeOffsetType visitLoadInst(LoadInst &I)
Definition: MemoryBuiltins.cpp:979
llvm::ObjectSizeOffsetEvaluator::knownOffset
bool knownOffset(SizeOffsetEvalType SizeOffset)
Definition: MemoryBuiltins.h:290
llvm::ObjectSizeOffsetVisitor::visitInstruction
SizeOffsetType visitInstruction(Instruction &I)
Definition: MemoryBuiltins.cpp:1032
llvm::ObjectSizeOffsetVisitor::visitCallBase
SizeOffsetType visitCallBase(CallBase &CB)
Definition: MemoryBuiltins.cpp:819
llvm::ObjectSizeOffsetVisitor::visitArgument
SizeOffsetType visitArgument(Argument &A)
Definition: MemoryBuiltins.cpp:807
llvm::ObjectSizeOpts::Mode
Mode
Controls how we handle conditional statements with unknown conditions.
Definition: MemoryBuiltins.h:140
llvm::getAllocationFamily
Optional< StringRef > getAllocationFamily(const Value *I, const TargetLibraryInfo *TLI)
If a function is part of an allocation family (e.g.
Definition: MemoryBuiltins.cpp:535
llvm::ObjectSizeOpts::EvalMode
Mode EvalMode
How we want to evaluate this object's size.
Definition: MemoryBuiltins.h:155
llvm::ExtractValueInst
This instruction extracts a struct member or array element value from an aggregate value.
Definition: Instructions.h:2446
llvm::getAllocAlignment
Value * getAllocAlignment(const CallBase *V, const TargetLibraryInfo *TLI)
Gets the alignment argument for an aligned_alloc-like function, using either built-in knowledge based...
Definition: MemoryBuiltins.cpp:372
llvm::getAllocSize
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.
Definition: MemoryBuiltins.cpp:398
llvm::SizeOffsetEvalType
std::pair< Value *, Value * > SizeOffsetEvalType
Definition: MemoryBuiltins.h:252
llvm::isRemovableAlloc
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...
Definition: MemoryBuiltins.cpp:361
llvm::ObjectSizeOffsetVisitor::knownOffset
static bool knownOffset(const SizeOffsetType &SizeOffset)
Definition: MemoryBuiltins.h:217
llvm::TargetStackID::Value
Value
Definition: TargetFrameLowering.h:27
llvm::TargetLibraryInfo
Provides information about what library functions are available for the current target.
Definition: TargetLibraryInfo.h:226
llvm::IntToPtrInst
This class represents a cast from an integer to a pointer.
Definition: Instructions.h:5162
llvm::ObjectSizeOffsetVisitor::compute
SizeOffsetType compute(Value *V)
Definition: MemoryBuiltins.cpp:720
llvm::ObjectSizeOffsetVisitor::visitConstantPointerNull
SizeOffsetType visitConstantPointerNull(ConstantPointerNull &)
Definition: MemoryBuiltins.cpp:826
llvm::ObjectSizeOffsetEvaluator::visitExtractValueInst
SizeOffsetEvalType visitExtractValueInst(ExtractValueInst &I)
Definition: MemoryBuiltins.cpp:1179
llvm::ObjectSizeOffsetEvaluator::visitInstruction
SizeOffsetEvalType visitInstruction(Instruction &I)
Definition: MemoryBuiltins.cpp:1261
llvm::ObjectSizeOffsetVisitor::knownSize
static bool knownSize(const SizeOffsetType &SizeOffset)
Definition: MemoryBuiltins.h:213
llvm::PHINode
Definition: Instructions.h:2699
llvm::ObjectSizeOffsetEvaluator::bothKnown
bool bothKnown(SizeOffsetEvalType SizeOffset)
Definition: MemoryBuiltins.h:298
llvm::CallBase
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Definition: InstrTypes.h:1175
llvm::ObjectSizeOffsetVisitor::ObjectSizeOffsetVisitor
ObjectSizeOffsetVisitor(const DataLayout &DL, const TargetLibraryInfo *TLI, LLVMContext &Context, ObjectSizeOpts Options={})
Definition: MemoryBuiltins.cpp:711
BB
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
Definition: README.txt:39
GEP
Hexagon Common GEP
Definition: HexagonCommonGEP.cpp:171
From
BlockVerifier::State From
Definition: BlockVerifier.cpp:55
llvm::AllocaInst
an instruction to allocate memory on the stack
Definition: Instructions.h:59
llvm::isLibFreeFunction
bool isLibFreeFunction(const Function *F, const LibFunc TLIFn)
isLibFreeFunction - Returns true if the function is a builtin free()
Definition: MemoryBuiltins.cpp:563
llvm::ObjectSizeOffsetVisitor::visitExtractElementInst
SizeOffsetType visitExtractElementInst(ExtractElementInst &I)
Definition: MemoryBuiltins.cpp:840
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
llvm::ObjectSizeOffsetEvaluator::anyKnown
bool anyKnown(SizeOffsetEvalType SizeOffset)
Definition: MemoryBuiltins.h:294
llvm::isMallocOrCallocLikeFn
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...
Definition: MemoryBuiltins.cpp:332
llvm::ObjectSizeOffsetVisitor::visitPHINode
SizeOffsetType visitPHINode(PHINode &)
Definition: MemoryBuiltins.cpp:1014