LLVM
15.0.0git
|
Holds information about the memory runtime legality checks to verify that a group of pointers do not overlap. More...
#include "llvm/Analysis/LoopAccessAnalysis.h"
Classes | |
struct | PointerInfo |
Public Member Functions | |
RuntimePointerChecking (MemoryDepChecker &DC, ScalarEvolution *SE) | |
void | reset () |
Reset the state of the pointer runtime information. More... | |
void | insert (Loop *Lp, Value *Ptr, const SCEV *PtrExpr, Type *AccessTy, bool WritePtr, unsigned DepSetId, unsigned ASId, PredicatedScalarEvolution &PSE) |
Insert a pointer and calculate the start and end SCEVs. More... | |
bool | empty () const |
No run-time memory checking is necessary. More... | |
void | generateChecks (MemoryDepChecker::DepCandidates &DepCands, bool UseDependencies) |
Generate the checks and store it. More... | |
const SmallVectorImpl< RuntimePointerCheck > & | getChecks () const |
Returns the checks that generateChecks created. More... | |
Optional< ArrayRef< PointerDiffInfo > > | getDiffChecks () const |
bool | needsChecking (const RuntimeCheckingPtrGroup &M, const RuntimeCheckingPtrGroup &N) const |
Decide if we need to add a check between two groups of pointers, according to needsChecking. More... | |
unsigned | getNumberOfChecks () const |
Returns the number of run-time checks required according to needsChecking. More... | |
void | print (raw_ostream &OS, unsigned Depth=0) const |
Print the list run-time memory checks necessary. More... | |
void | printChecks (raw_ostream &OS, const SmallVectorImpl< RuntimePointerCheck > &Checks, unsigned Depth=0) const |
Print Checks . More... | |
bool | needsChecking (unsigned I, unsigned J) const |
Decide whether we need to issue a run-time check for pointer at index I and J to prove their independence. More... | |
const PointerInfo & | getPointerInfo (unsigned PtrIdx) const |
Return PointerInfo for pointer at index PtrIdx . More... | |
ScalarEvolution * | getSE () const |
Static Public Member Functions | |
static bool | arePointersInSamePartition (const SmallVectorImpl< int > &PtrToPartition, unsigned PtrIdx1, unsigned PtrIdx2) |
Check if pointers are in the same partition. More... | |
Public Attributes | |
bool | Need = false |
This flag indicates if we need to add the runtime check. More... | |
SmallVector< PointerInfo, 2 > | Pointers |
Information about the pointers that may require checking. More... | |
SmallVector< RuntimeCheckingPtrGroup, 2 > | CheckingGroups |
Holds a partitioning of pointers into "check groups". More... | |
Friends | |
struct | RuntimeCheckingPtrGroup |
Holds information about the memory runtime legality checks to verify that a group of pointers do not overlap.
Definition at line 383 of file LoopAccessAnalysis.h.
|
inline |
Definition at line 414 of file LoopAccessAnalysis.h.
|
static |
Check if pointers are in the same partition.
PtrToPartition
contains the partition number for pointers (-1 if the pointer belongs to multiple partitions).
Definition at line 530 of file LoopAccessAnalysis.cpp.
|
inline |
No run-time memory checking is necessary.
Definition at line 434 of file LoopAccessAnalysis.h.
References Pointers.
void RuntimePointerChecking::generateChecks | ( | MemoryDepChecker::DepCandidates & | DepCands, |
bool | UseDependencies | ||
) |
Generate the checks and store it.
This also performs the grouping of pointers to reduce the number of memchecks necessary.
Definition at line 337 of file LoopAccessAnalysis.cpp.
References assert(), and generateChecks().
Referenced by generateChecks().
|
inline |
Returns the checks that generateChecks created.
They can be used to ensure no read/write accesses overlap across all loop iterations.
Definition at line 443 of file LoopAccessAnalysis.h.
Referenced by llvm::InnerLoopVectorizer::emitMemRuntimeChecks().
|
inline |
Definition at line 452 of file LoopAccessAnalysis.h.
References llvm::None.
Referenced by llvm::InnerLoopVectorizer::emitMemRuntimeChecks().
|
inline |
Returns the number of run-time checks required according to needsChecking.
Definition at line 465 of file LoopAccessAnalysis.h.
|
inline |
Return PointerInfo for pointer at index PtrIdx
.
Definition at line 497 of file LoopAccessAnalysis.h.
References Pointers.
Referenced by llvm::LoopVersioning::prepareNoAliasMetadata().
|
inline |
Definition at line 501 of file LoopAccessAnalysis.h.
void RuntimePointerChecking::insert | ( | Loop * | Lp, |
Value * | Ptr, | ||
const SCEV * | PtrExpr, | ||
Type * | AccessTy, | ||
bool | WritePtr, | ||
unsigned | DepSetId, | ||
unsigned | ASId, | ||
PredicatedScalarEvolution & | PSE | ||
) |
Insert a pointer and calculate the start and end SCEVs.
Calculate Start and End points of memory access.
We need PSE
in order to compute the SCEV expression of the pointer according to the assumptions that we've made during the analysis. The method might also version the pointer stride according to Strides
, and add new predicates to PSE
.
Let's assume A is the first access and B is a memory access on N-th loop iteration. Then B is calculated as: B = A + Step*N . Step value may be positive or negative. N is a calculated back-edge taken count: N = (TripCount > 0) ? RoundDown(TripCount -1 , VF) : 0 Start and End points are calculated in the following way: Start = UMIN(A, B) ; End = UMAX(A, B) + SizeOfElt, where SizeOfElt is the size of single memory access in bytes.
There is no conflict when the intervals are disjoint: NoConflict = (P2.Start >= P1.End) || (P1.Start >= P2.End)
Definition at line 193 of file LoopAccessAnalysis.cpp.
References assert(), DL, llvm::SCEVAddRecExpr::evaluateAtIteration(), llvm::ScalarEvolution::getAddExpr(), llvm::PredicatedScalarEvolution::getBackedgeTakenCount(), llvm::Module::getDataLayout(), llvm::LoopBase< BlockT, LoopT >::getHeader(), llvm::BasicBlock::getModule(), llvm::PredicatedScalarEvolution::getSE(), llvm::SCEVAddRecExpr::getStart(), llvm::SCEVAddRecExpr::getStepRecurrence(), llvm::ScalarEvolution::getStoreSizeOfExpr(), llvm::Value::getType(), llvm::ScalarEvolution::getUMaxExpr(), llvm::ScalarEvolution::getUMinExpr(), llvm::ScalarEvolution::isLoopInvariant(), Pointers, and std::swap().
bool RuntimePointerChecking::needsChecking | ( | const RuntimeCheckingPtrGroup & | M, |
const RuntimeCheckingPtrGroup & | N | ||
) | const |
Decide if we need to add a check between two groups of pointers, according to needsChecking.
Definition at line 344 of file LoopAccessAnalysis.cpp.
bool RuntimePointerChecking::needsChecking | ( | unsigned | I, |
unsigned | J | ||
) | const |
Decide whether we need to issue a run-time check for pointer at index I
and J
to prove their independence.
Definition at line 537 of file LoopAccessAnalysis.cpp.
References llvm::RuntimePointerChecking::PointerInfo::AliasSetId, llvm::RuntimePointerChecking::PointerInfo::DependencySetId, I, llvm::RuntimePointerChecking::PointerInfo::IsWritePtr, and Pointers.
void RuntimePointerChecking::print | ( | raw_ostream & | OS, |
unsigned | Depth = 0 |
||
) | const |
Print the list run-time memory checks necessary.
Definition at line 575 of file LoopAccessAnalysis.cpp.
References CheckingGroups, llvm::Depth, I, llvm::raw_ostream::indent(), Pointers, and printChecks().
void RuntimePointerChecking::printChecks | ( | raw_ostream & | OS, |
const SmallVectorImpl< RuntimePointerCheck > & | Checks, | ||
unsigned | Depth = 0 |
||
) | const |
Print Checks
.
Definition at line 556 of file LoopAccessAnalysis.cpp.
References Check, llvm::Depth, First, llvm::raw_ostream::indent(), N, and Pointers.
Referenced by print().
|
inline |
Reset the state of the pointer runtime information.
Definition at line 418 of file LoopAccessAnalysis.h.
References llvm::SmallVectorImpl< T >::clear(), Need, and Pointers.
|
friend |
Definition at line 384 of file LoopAccessAnalysis.h.
SmallVector<RuntimeCheckingPtrGroup, 2> llvm::RuntimePointerChecking::CheckingGroups |
Holds a partitioning of pointers into "check groups".
Definition at line 482 of file LoopAccessAnalysis.h.
Referenced by llvm::LoopVersioning::prepareNoAliasMetadata(), and print().
bool llvm::RuntimePointerChecking::Need = false |
This flag indicates if we need to add the runtime check.
Definition at line 476 of file LoopAccessAnalysis.h.
Referenced by llvm::LoopVectorizationLegality::canVectorize(), llvm::LoopVectorizationCostModel::computeMaxVF(), reset(), llvm::LoopVectorizationCostModel::runtimeChecksRequired(), and llvm::LoopVectorizationCostModel::selectInterleaveCount().
SmallVector<PointerInfo, 2> llvm::RuntimePointerChecking::Pointers |
Information about the pointers that may require checking.
Definition at line 479 of file LoopAccessAnalysis.h.
Referenced by llvm::RuntimeCheckingPtrGroup::addPointer(), empty(), getPointerInfo(), insert(), needsChecking(), print(), printChecks(), and reset().