LLVM  10.0.0svn
Loads.cpp
Go to the documentation of this file.
1 //===- Loads.cpp - Local load analysis ------------------------------------===//
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 file defines simple local analyses for load instructions.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "llvm/Analysis/Loads.h"
16 #include "llvm/IR/DataLayout.h"
17 #include "llvm/IR/GlobalAlias.h"
18 #include "llvm/IR/GlobalVariable.h"
19 #include "llvm/IR/IntrinsicInst.h"
20 #include "llvm/IR/LLVMContext.h"
21 #include "llvm/IR/Module.h"
22 #include "llvm/IR/Operator.h"
23 #include "llvm/IR/Statepoint.h"
24 
25 using namespace llvm;
26 
27 static bool isAligned(const Value *Base, const APInt &Offset, unsigned Align,
28  const DataLayout &DL) {
29  APInt BaseAlign(Offset.getBitWidth(), Base->getPointerAlignment(DL));
30 
31  if (!BaseAlign) {
32  Type *Ty = Base->getType()->getPointerElementType();
33  if (!Ty->isSized())
34  return false;
35  BaseAlign = DL.getABITypeAlignment(Ty);
36  }
37 
38  APInt Alignment(Offset.getBitWidth(), Align);
39 
40  assert(Alignment.isPowerOf2() && "must be a power of 2!");
41  return BaseAlign.uge(Alignment) && !(Offset & (Alignment-1));
42 }
43 
44 static bool isAligned(const Value *Base, unsigned Align, const DataLayout &DL) {
45  Type *Ty = Base->getType();
46  assert(Ty->isSized() && "must be sized");
48  return isAligned(Base, Offset, Align, DL);
49 }
50 
51 /// Test if V is always a pointer to allocated and suitably aligned memory for
52 /// a simple load or store.
54  const Value *V, unsigned Align, const APInt &Size, const DataLayout &DL,
55  const Instruction *CtxI, const DominatorTree *DT,
57  // Already visited? Bail out, we've likely hit unreachable code.
58  if (!Visited.insert(V).second)
59  return false;
60 
61  // Note that it is not safe to speculate into a malloc'd region because
62  // malloc may return null.
63 
64  // bitcast instructions are no-ops as far as dereferenceability is concerned.
65  if (const BitCastOperator *BC = dyn_cast<BitCastOperator>(V))
66  return isDereferenceableAndAlignedPointer(BC->getOperand(0), Align, Size,
67  DL, CtxI, DT, Visited);
68 
69  bool CheckForNonNull = false;
70  APInt KnownDerefBytes(Size.getBitWidth(),
71  V->getPointerDereferenceableBytes(DL, CheckForNonNull));
72  if (KnownDerefBytes.getBoolValue()) {
73  if (KnownDerefBytes.uge(Size))
74  if (!CheckForNonNull || isKnownNonZero(V, DL, 0, nullptr, CtxI, DT))
75  return isAligned(V, Align, DL);
76  }
77 
78  // For GEPs, determine if the indexing lands within the allocated object.
79  if (const GEPOperator *GEP = dyn_cast<GEPOperator>(V)) {
80  const Value *Base = GEP->getPointerOperand();
81 
82  APInt Offset(DL.getIndexTypeSizeInBits(GEP->getType()), 0);
83  if (!GEP->accumulateConstantOffset(DL, Offset) || Offset.isNegative() ||
84  !Offset.urem(APInt(Offset.getBitWidth(), Align)).isMinValue())
85  return false;
86 
87  // If the base pointer is dereferenceable for Offset+Size bytes, then the
88  // GEP (== Base + Offset) is dereferenceable for Size bytes. If the base
89  // pointer is aligned to Align bytes, and the Offset is divisible by Align
90  // then the GEP (== Base + Offset == k_0 * Align + k_1 * Align) is also
91  // aligned to Align bytes.
92 
93  // Offset and Size may have different bit widths if we have visited an
94  // addrspacecast, so we can't do arithmetic directly on the APInt values.
96  Base, Align, Offset + Size.sextOrTrunc(Offset.getBitWidth()),
97  DL, CtxI, DT, Visited);
98  }
99 
100  // For gc.relocate, look through relocations
101  if (const GCRelocateInst *RelocateInst = dyn_cast<GCRelocateInst>(V))
103  RelocateInst->getDerivedPtr(), Align, Size, DL, CtxI, DT, Visited);
104 
105  if (const AddrSpaceCastInst *ASC = dyn_cast<AddrSpaceCastInst>(V))
106  return isDereferenceableAndAlignedPointer(ASC->getOperand(0), Align, Size,
107  DL, CtxI, DT, Visited);
108 
109  if (const auto *Call = dyn_cast<CallBase>(V))
110  if (auto *RP = getArgumentAliasingToReturnedPointer(Call, true))
111  return isDereferenceableAndAlignedPointer(RP, Align, Size, DL, CtxI, DT,
112  Visited);
113 
114  // If we don't know, assume the worst.
115  return false;
116 }
117 
119  const APInt &Size,
120  const DataLayout &DL,
121  const Instruction *CtxI,
122  const DominatorTree *DT) {
124  return ::isDereferenceableAndAlignedPointer(V, Align, Size, DL, CtxI, DT,
125  Visited);
126 }
127 
129  unsigned Align,
130  const DataLayout &DL,
131  const Instruction *CtxI,
132  const DominatorTree *DT) {
133  // When dereferenceability information is provided by a dereferenceable
134  // attribute, we know exactly how many bytes are dereferenceable. If we can
135  // determine the exact offset to the attributed variable, we can use that
136  // information here.
137 
138  // Require ABI alignment for loads without alignment specification
139  if (Align == 0)
140  Align = DL.getABITypeAlignment(Ty);
141 
142  if (!Ty->isSized())
143  return false;
144 
147  V, Align,
149  DL, CtxI, DT, Visited);
150 }
151 
153  const DataLayout &DL,
154  const Instruction *CtxI,
155  const DominatorTree *DT) {
156  return isDereferenceableAndAlignedPointer(V, Ty, 1, DL, CtxI, DT);
157 }
158 
159 /// Test if A and B will obviously have the same value.
160 ///
161 /// This includes recognizing that %t0 and %t1 will have the same
162 /// value in code like this:
163 /// \code
164 /// %t0 = getelementptr \@a, 0, 3
165 /// store i32 0, i32* %t0
166 /// %t1 = getelementptr \@a, 0, 3
167 /// %t2 = load i32* %t1
168 /// \endcode
169 ///
170 static bool AreEquivalentAddressValues(const Value *A, const Value *B) {
171  // Test if the values are trivially equivalent.
172  if (A == B)
173  return true;
174 
175  // Test if the values come from identical arithmetic instructions.
176  // Use isIdenticalToWhenDefined instead of isIdenticalTo because
177  // this function is only used when one address use dominates the
178  // other, which means that they'll always either have the same
179  // value or one of them will have an undefined value.
180  if (isa<BinaryOperator>(A) || isa<CastInst>(A) || isa<PHINode>(A) ||
181  isa<GetElementPtrInst>(A))
182  if (const Instruction *BI = dyn_cast<Instruction>(B))
183  if (cast<Instruction>(A)->isIdenticalToWhenDefined(BI))
184  return true;
185 
186  // Otherwise they may not be equivalent.
187  return false;
188 }
189 
190 /// Check if executing a load of this pointer value cannot trap.
191 ///
192 /// If DT and ScanFrom are specified this method performs context-sensitive
193 /// analysis and returns true if it is safe to load immediately before ScanFrom.
194 ///
195 /// If it is not obviously safe to load from the specified pointer, we do
196 /// a quick local scan of the basic block containing \c ScanFrom, to determine
197 /// if the address is already accessed.
198 ///
199 /// This uses the pointee type to determine how many bytes need to be safe to
200 /// load from the pointer.
202  const DataLayout &DL,
203  Instruction *ScanFrom,
204  const DominatorTree *DT) {
205  // Zero alignment means that the load has the ABI alignment for the target
206  if (Align == 0)
208  assert(isPowerOf2_32(Align));
209 
210  // If DT is not specified we can't make context-sensitive query
211  const Instruction* CtxI = DT ? ScanFrom : nullptr;
212  if (isDereferenceableAndAlignedPointer(V, Align, Size, DL, CtxI, DT))
213  return true;
214 
215  int64_t ByteOffset = 0;
216  Value *Base = V;
217  Base = GetPointerBaseWithConstantOffset(V, ByteOffset, DL);
218 
219  if (ByteOffset < 0) // out of bounds
220  return false;
221 
222  Type *BaseType = nullptr;
223  unsigned BaseAlign = 0;
224  if (const AllocaInst *AI = dyn_cast<AllocaInst>(Base)) {
225  // An alloca is safe to load from as load as it is suitably aligned.
226  BaseType = AI->getAllocatedType();
227  BaseAlign = AI->getAlignment();
228  } else if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(Base)) {
229  // Global variables are not necessarily safe to load from if they are
230  // interposed arbitrarily. Their size may change or they may be weak and
231  // require a test to determine if they were in fact provided.
232  if (!GV->isInterposable()) {
233  BaseType = GV->getType()->getElementType();
234  BaseAlign = GV->getAlignment();
235  }
236  }
237 
238  PointerType *AddrTy = cast<PointerType>(V->getType());
239  uint64_t LoadSize = DL.getTypeStoreSize(AddrTy->getElementType());
240 
241  // If we found a base allocated type from either an alloca or global variable,
242  // try to see if we are definitively within the allocated region. We need to
243  // know the size of the base type and the loaded type to do anything in this
244  // case.
245  if (BaseType && BaseType->isSized()) {
246  if (BaseAlign == 0)
247  BaseAlign = DL.getPrefTypeAlignment(BaseType);
248 
249  if (Align <= BaseAlign) {
250  // Check if the load is within the bounds of the underlying object.
251  if (ByteOffset + LoadSize <= DL.getTypeAllocSize(BaseType) &&
252  ((ByteOffset % Align) == 0))
253  return true;
254  }
255  }
256 
257  if (!ScanFrom)
258  return false;
259 
260  // Otherwise, be a little bit aggressive by scanning the local block where we
261  // want to check to see if the pointer is already being loaded or stored
262  // from/to. If so, the previous load or store would have already trapped,
263  // so there is no harm doing an extra load (also, CSE will later eliminate
264  // the load entirely).
265  BasicBlock::iterator BBI = ScanFrom->getIterator(),
266  E = ScanFrom->getParent()->begin();
267 
268  // We can at least always strip pointer casts even though we can't use the
269  // base here.
270  V = V->stripPointerCasts();
271 
272  while (BBI != E) {
273  --BBI;
274 
275  // If we see a free or a call which may write to memory (i.e. which might do
276  // a free) the pointer could be marked invalid.
277  if (isa<CallInst>(BBI) && BBI->mayWriteToMemory() &&
278  !isa<DbgInfoIntrinsic>(BBI))
279  return false;
280 
281  Value *AccessedPtr;
282  unsigned AccessedAlign;
283  if (LoadInst *LI = dyn_cast<LoadInst>(BBI)) {
284  // Ignore volatile loads. The execution of a volatile load cannot
285  // be used to prove an address is backed by regular memory; it can,
286  // for example, point to an MMIO register.
287  if (LI->isVolatile())
288  continue;
289  AccessedPtr = LI->getPointerOperand();
290  AccessedAlign = LI->getAlignment();
291  } else if (StoreInst *SI = dyn_cast<StoreInst>(BBI)) {
292  // Ignore volatile stores (see comment for loads).
293  if (SI->isVolatile())
294  continue;
295  AccessedPtr = SI->getPointerOperand();
296  AccessedAlign = SI->getAlignment();
297  } else
298  continue;
299 
300  Type *AccessedTy = AccessedPtr->getType()->getPointerElementType();
301  if (AccessedAlign == 0)
302  AccessedAlign = DL.getABITypeAlignment(AccessedTy);
303  if (AccessedAlign < Align)
304  continue;
305 
306  // Handle trivial cases.
307  if (AccessedPtr == V)
308  return true;
309 
310  if (AreEquivalentAddressValues(AccessedPtr->stripPointerCasts(), V) &&
311  LoadSize <= DL.getTypeStoreSize(AccessedTy))
312  return true;
313  }
314  return false;
315 }
316 
318  const DataLayout &DL,
319  Instruction *ScanFrom,
320  const DominatorTree *DT) {
322  return isSafeToLoadUnconditionally(V, Align, Size, DL, ScanFrom, DT);
323 }
324 
325  /// DefMaxInstsToScan - the default number of maximum instructions
326 /// to scan in the block, used by FindAvailableLoadedValue().
327 /// FindAvailableLoadedValue() was introduced in r60148, to improve jump
328 /// threading in part by eliminating partially redundant loads.
329 /// At that point, the value of MaxInstsToScan was already set to '6'
330 /// without documented explanation.
332 llvm::DefMaxInstsToScan("available-load-scan-limit", cl::init(6), cl::Hidden,
333  cl::desc("Use this to specify the default maximum number of instructions "
334  "to scan backward from a given instruction, when searching for "
335  "available loaded value"));
336 
338  BasicBlock *ScanBB,
339  BasicBlock::iterator &ScanFrom,
340  unsigned MaxInstsToScan,
341  AliasAnalysis *AA, bool *IsLoad,
342  unsigned *NumScanedInst) {
343  // Don't CSE load that is volatile or anything stronger than unordered.
344  if (!Load->isUnordered())
345  return nullptr;
346 
348  Load->getPointerOperand(), Load->getType(), Load->isAtomic(), ScanBB,
349  ScanFrom, MaxInstsToScan, AA, IsLoad, NumScanedInst);
350 }
351 
353  bool AtLeastAtomic, BasicBlock *ScanBB,
354  BasicBlock::iterator &ScanFrom,
355  unsigned MaxInstsToScan,
356  AliasAnalysis *AA, bool *IsLoadCSE,
357  unsigned *NumScanedInst) {
358  if (MaxInstsToScan == 0)
359  MaxInstsToScan = ~0U;
360 
361  const DataLayout &DL = ScanBB->getModule()->getDataLayout();
362 
363  // Try to get the store size for the type.
364  auto AccessSize = LocationSize::precise(DL.getTypeStoreSize(AccessTy));
365 
366  Value *StrippedPtr = Ptr->stripPointerCasts();
367 
368  while (ScanFrom != ScanBB->begin()) {
369  // We must ignore debug info directives when counting (otherwise they
370  // would affect codegen).
371  Instruction *Inst = &*--ScanFrom;
372  if (isa<DbgInfoIntrinsic>(Inst))
373  continue;
374 
375  // Restore ScanFrom to expected value in case next test succeeds
376  ScanFrom++;
377 
378  if (NumScanedInst)
379  ++(*NumScanedInst);
380 
381  // Don't scan huge blocks.
382  if (MaxInstsToScan-- == 0)
383  return nullptr;
384 
385  --ScanFrom;
386  // If this is a load of Ptr, the loaded value is available.
387  // (This is true even if the load is volatile or atomic, although
388  // those cases are unlikely.)
389  if (LoadInst *LI = dyn_cast<LoadInst>(Inst))
391  LI->getPointerOperand()->stripPointerCasts(), StrippedPtr) &&
392  CastInst::isBitOrNoopPointerCastable(LI->getType(), AccessTy, DL)) {
393 
394  // We can value forward from an atomic to a non-atomic, but not the
395  // other way around.
396  if (LI->isAtomic() < AtLeastAtomic)
397  return nullptr;
398 
399  if (IsLoadCSE)
400  *IsLoadCSE = true;
401  return LI;
402  }
403 
404  if (StoreInst *SI = dyn_cast<StoreInst>(Inst)) {
405  Value *StorePtr = SI->getPointerOperand()->stripPointerCasts();
406  // If this is a store through Ptr, the value is available!
407  // (This is true even if the store is volatile or atomic, although
408  // those cases are unlikely.)
409  if (AreEquivalentAddressValues(StorePtr, StrippedPtr) &&
410  CastInst::isBitOrNoopPointerCastable(SI->getValueOperand()->getType(),
411  AccessTy, DL)) {
412 
413  // We can value forward from an atomic to a non-atomic, but not the
414  // other way around.
415  if (SI->isAtomic() < AtLeastAtomic)
416  return nullptr;
417 
418  if (IsLoadCSE)
419  *IsLoadCSE = false;
420  return SI->getOperand(0);
421  }
422 
423  // If both StrippedPtr and StorePtr reach all the way to an alloca or
424  // global and they are different, ignore the store. This is a trivial form
425  // of alias analysis that is important for reg2mem'd code.
426  if ((isa<AllocaInst>(StrippedPtr) || isa<GlobalVariable>(StrippedPtr)) &&
427  (isa<AllocaInst>(StorePtr) || isa<GlobalVariable>(StorePtr)) &&
428  StrippedPtr != StorePtr)
429  continue;
430 
431  // If we have alias analysis and it says the store won't modify the loaded
432  // value, ignore the store.
433  if (AA && !isModSet(AA->getModRefInfo(SI, StrippedPtr, AccessSize)))
434  continue;
435 
436  // Otherwise the store that may or may not alias the pointer, bail out.
437  ++ScanFrom;
438  return nullptr;
439  }
440 
441  // If this is some other instruction that may clobber Ptr, bail out.
442  if (Inst->mayWriteToMemory()) {
443  // If alias analysis claims that it really won't modify the load,
444  // ignore it.
445  if (AA && !isModSet(AA->getModRefInfo(Inst, StrippedPtr, AccessSize)))
446  continue;
447 
448  // May modify the pointer, bail out.
449  ++ScanFrom;
450  return nullptr;
451  }
452  }
453 
454  // Got to the start of the block, we didn't find it, but are done for this
455  // block.
456  return nullptr;
457 }
A parsed version of the target data layout string in and methods for querying it. ...
Definition: DataLayout.h:111
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
uint64_t getTypeStoreSizeInBits(Type *Ty) const
Returns the maximum number of bits that may be overwritten by storing the specified type; always a mu...
Definition: DataLayout.h:453
This class represents lattice values for constants.
Definition: AllocatorList.h:23
bool isAtomic() const
Return true if this instruction has an AtomicOrdering of unordered or higher.
bool isSized(SmallPtrSetImpl< Type *> *Visited=nullptr) const
Return true if it makes sense to take the size of this type.
Definition: Type.h:264
cl::opt< unsigned > DefMaxInstsToScan
The default number of maximum instructions to scan in the block, used by FindAvailableLoadedValue().
bool isSafeToLoadUnconditionally(Value *V, unsigned Align, APInt &Size, const DataLayout &DL, Instruction *ScanFrom=nullptr, const DominatorTree *DT=nullptr)
Return true if we know that executing a load from this value cannot trap.
Definition: Loads.cpp:201
bool mayWriteToMemory() const
Return true if this instruction may modify memory.
static LocationSize precise(uint64_t Value)
Value * FindAvailablePtrLoadStore(Value *Ptr, Type *AccessTy, bool AtLeastAtomic, BasicBlock *ScanBB, BasicBlock::iterator &ScanFrom, unsigned MaxInstsToScan, AliasAnalysis *AA, bool *IsLoad, unsigned *NumScanedInst)
Scan backwards to see if we have the value of the given pointer available locally within a small numb...
Definition: Loads.cpp:352
An instruction for reading from memory.
Definition: Instructions.h:167
Hexagon Common GEP
bool isDereferenceableAndAlignedPointer(const Value *V, Type *Ty, unsigned Align, const DataLayout &DL, const Instruction *CtxI=nullptr, const DominatorTree *DT=nullptr)
Returns true if V is always a dereferenceable pointer with alignment greater or equal than requested...
Definition: Loads.cpp:128
unsigned getBitWidth() const
Return the number of bits in the APInt.
Definition: APInt.h:1515
unsigned getPointerAlignment(const DataLayout &DL) const
Returns an alignment of the pointer value.
Definition: Value.cpp:678
static bool isBitOrNoopPointerCastable(Type *SrcTy, Type *DestTy, const DataLayout &DL)
Check whether a bitcast, inttoptr, or ptrtoint cast between these types is valid and a no-op...
iterator begin()
Instruction iterator methods.
Definition: BasicBlock.h:268
const Module * getModule() const
Return the module owning the function this basic block belongs to, or nullptr if the function does no...
Definition: BasicBlock.cpp:133
This class represents a conversion between pointers from one address space to another.
Type * getPointerElementType() const
Definition: Type.h:376
const DataLayout & getDataLayout() const
Get the data layout for the module&#39;s target platform.
Definition: Module.cpp:369
Value * FindAvailableLoadedValue(LoadInst *Load, BasicBlock *ScanBB, BasicBlock::iterator &ScanFrom, unsigned MaxInstsToScan=DefMaxInstsToScan, AliasAnalysis *AA=nullptr, bool *IsLoadCSE=nullptr, unsigned *NumScanedInst=nullptr)
Scan backwards to see if we have the value of the given load available locally within a small number ...
Definition: Loads.cpp:337
static bool isDereferenceableAndAlignedPointer(const Value *V, unsigned Align, const APInt &Size, const DataLayout &DL, const Instruction *CtxI, const DominatorTree *DT, SmallPtrSetImpl< const Value *> &Visited)
Test if V is always a pointer to allocated and suitably aligned memory for a simple load or store...
Definition: Loads.cpp:53
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:245
An instruction for storing to memory.
Definition: Instructions.h:320
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
Definition: Dominators.h:144
Class to represent pointers.
Definition: DerivedTypes.h:544
bool isNegative() const
Determine sign of this APInt.
Definition: APInt.h:363
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:432
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
APInt urem(const APInt &RHS) const
Unsigned remainder operation.
Definition: APInt.cpp:1617
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
Definition: MathExtras.h:428
LLVM Basic Block Representation.
Definition: BasicBlock.h:57
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:45
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
Definition: SmallPtrSet.h:370
unsigned getPrefTypeAlignment(Type *Ty) const
Returns the preferred stack/global alignment for the specified type.
Definition: DataLayout.cpp:762
bool isUnordered() const
Definition: Instructions.h:278
Value * getPointerOperand()
Definition: Instructions.h:284
self_iterator getIterator()
Definition: ilist_node.h:81
unsigned getIndexTypeSizeInBits(Type *Ty) const
Layout size of the index used in GEP calculation.
Definition: DataLayout.cpp:684
const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs, address space casts, and aliases.
Definition: Value.cpp:531
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:40
BaseType
A given derived pointer can have multiple base pointers through phi/selects.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
Definition: SmallPtrSet.h:417
const Value * getArgumentAliasingToReturnedPointer(const CallBase *Call, bool MustPreserveNullness)
This function returns call pointer argument that is considered the same by aliasing rules...
bool isDereferenceablePointer(const Value *V, Type *Ty, const DataLayout &DL, const Instruction *CtxI=nullptr, const DominatorTree *DT=nullptr)
Return true if this is always a dereferenceable pointer.
Definition: Loads.cpp:152
Module.h This file contains the declarations for the Module class.
unsigned getABITypeAlignment(Type *Ty) const
Returns the minimum ABI-required alignment for the specified type.
Definition: DataLayout.cpp:752
uint64_t getPointerDereferenceableBytes(const DataLayout &DL, bool &CanBeNull) const
Returns the number of bytes known to be dereferenceable for the pointer value.
Definition: Value.cpp:612
bool isAligned(Align Lhs, uint64_t SizeInBytes)
Checks that SizeInBytes is a multiple of the alignment.
Definition: Alignment.h:114
static bool AreEquivalentAddressValues(const Value *A, const Value *B)
Test if A and B will obviously have the same value.
Definition: Loads.cpp:170
Class for arbitrary precision integers.
Definition: APInt.h:69
bool isKnownNonZero(const Value *V, const DataLayout &DL, unsigned Depth=0, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr, bool UseInstrInfo=true)
Return true if the given value is known to be non-zero when defined.
InstListType::iterator iterator
Instruction iterators...
Definition: BasicBlock.h:89
uint64_t getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
Definition: DataLayout.h:470
LLVM_NODISCARD bool isModSet(const ModRefInfo MRI)
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
uint32_t Size
Definition: Profile.cpp:46
bool isMinValue() const
Determine if this is the smallest unsigned value.
Definition: APInt.h:436
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Represents calls to the gc.relocate intrinsic.
Definition: Statepoint.h:360
LLVM Value Representation.
Definition: Value.h:73
uint64_t getTypeStoreSize(Type *Ty) const
Returns the maximum number of bytes that may be overwritten by storing the specified type...
Definition: DataLayout.h:445
Value * GetPointerBaseWithConstantOffset(Value *Ptr, int64_t &Offset, const DataLayout &DL)
Analyze the specified pointer to see if it can be expressed as a base pointer plus a constant offset...
ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc)
getModRefInfo (for call sites) - Return information about whether a particular call site modifies or ...
Type * getElementType() const
Definition: DerivedTypes.h:563
const BasicBlock * getParent() const
Definition: Instruction.h:66
an instruction to allocate memory on the stack
Definition: Instructions.h:59