LLVM 22.0.0git
llvm::RuntimePointerChecking Class Reference

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, std::optional< ScalarEvolution::LoopGuards > &LoopGuards)
void reset ()
 Reset the state of the pointer runtime information.
LLVM_ABI void insert (Loop *Lp, Value *Ptr, const SCEV *PtrExpr, Type *AccessTy, bool WritePtr, unsigned DepSetId, unsigned ASId, PredicatedScalarEvolution &PSE, bool NeedsFreeze)
 Insert a pointer and calculate the start and end SCEVs.
bool empty () const
 No run-time memory checking is necessary.
LLVM_ABI void generateChecks (MemoryDepChecker::DepCandidates &DepCands, bool UseDependencies)
 Generate the checks and store it.
const SmallVectorImpl< RuntimePointerCheck > & getChecks () const
 Returns the checks that generateChecks created.
std::optional< ArrayRef< PointerDiffInfo > > getDiffChecks () const
LLVM_ABI 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.
unsigned getNumberOfChecks () const
 Returns the number of run-time checks required according to needsChecking.
LLVM_ABI void print (raw_ostream &OS, unsigned Depth=0) const
 Print the list run-time memory checks necessary.
LLVM_ABI void printChecks (raw_ostream &OS, const SmallVectorImpl< RuntimePointerCheck > &Checks, unsigned Depth=0) const
 Print Checks.
LLVM_ABI 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.
const PointerInfogetPointerInfo (unsigned PtrIdx) const
 Return PointerInfo for pointer at index PtrIdx.
ScalarEvolutiongetSE () const

Static Public Member Functions

static LLVM_ABI bool arePointersInSamePartition (const SmallVectorImpl< int > &PtrToPartition, unsigned PtrIdx1, unsigned PtrIdx2)
 Check if pointers are in the same partition.

Public Attributes

bool Need = false
 This flag indicates if we need to add the runtime check.
SmallVector< PointerInfo, 2 > Pointers
 Information about the pointers that may require checking.
SmallVector< RuntimeCheckingPtrGroup, 2 > CheckingGroups
 Holds a partitioning of pointers into "check groups".

Friends

struct RuntimeCheckingPtrGroup

Detailed Description

Holds information about the memory runtime legality checks to verify that a group of pointers do not overlap.

Definition at line 503 of file LoopAccessAnalysis.h.

Constructor & Destructor Documentation

◆ RuntimePointerChecking()

llvm::RuntimePointerChecking::RuntimePointerChecking ( MemoryDepChecker & DC,
ScalarEvolution * SE,
std::optional< ScalarEvolution::LoopGuards > & LoopGuards )
inline

Definition at line 536 of file LoopAccessAnalysis.h.

Member Function Documentation

◆ arePointersInSamePartition()

bool RuntimePointerChecking::arePointersInSamePartition ( const SmallVectorImpl< int > & PtrToPartition,
unsigned PtrIdx1,
unsigned PtrIdx2 )
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 717 of file LoopAccessAnalysis.cpp.

◆ empty()

bool llvm::RuntimePointerChecking::empty ( ) const
inline

No run-time memory checking is necessary.

Definition at line 561 of file LoopAccessAnalysis.h.

References Pointers.

◆ generateChecks()

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 528 of file LoopAccessAnalysis.cpp.

References assert(), and generateChecks().

Referenced by generateChecks().

◆ getChecks()

const SmallVectorImpl< RuntimePointerCheck > & llvm::RuntimePointerChecking::getChecks ( ) const
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 570 of file LoopAccessAnalysis.h.

◆ getDiffChecks()

std::optional< ArrayRef< PointerDiffInfo > > llvm::RuntimePointerChecking::getDiffChecks ( ) const
inline

Definition at line 579 of file LoopAccessAnalysis.h.

◆ getNumberOfChecks()

unsigned llvm::RuntimePointerChecking::getNumberOfChecks ( ) const
inline

Returns the number of run-time checks required according to needsChecking.

Definition at line 592 of file LoopAccessAnalysis.h.

◆ getPointerInfo()

const PointerInfo & llvm::RuntimePointerChecking::getPointerInfo ( unsigned PtrIdx) const
inline

Return PointerInfo for pointer at index PtrIdx.

Definition at line 624 of file LoopAccessAnalysis.h.

References Pointers.

Referenced by llvm::LoopVersioning::prepareNoAliasMetadata().

◆ getSE()

ScalarEvolution * llvm::RuntimePointerChecking::getSE ( ) const
inline

Definition at line 628 of file LoopAccessAnalysis.h.

◆ insert()

void RuntimePointerChecking::insert ( Loop * Lp,
Value * Ptr,
const SCEV * PtrExpr,
Type * AccessTy,
bool WritePtr,
unsigned DepSetId,
unsigned ASId,
PredicatedScalarEvolution & PSE,
bool NeedsFreeze )

Insert a pointer and calculate the start and end SCEVs.

Calculate Start and End points of memory access using getStartAndEndForAccess.

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.

Definition at line 389 of file LoopAccessAnalysis.cpp.

References assert(), llvm::PredicatedScalarEvolution::getBackedgeTakenCount(), llvm::PredicatedScalarEvolution::getSE(), llvm::getStartAndEndForAccess(), llvm::PredicatedScalarEvolution::getSymbolicMaxBackedgeTakenCount(), llvm::isa(), Pointers, and Ptr.

◆ needsChecking() [1/2]

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 535 of file LoopAccessAnalysis.cpp.

References I, N, needsChecking(), and RuntimeCheckingPtrGroup.

Referenced by needsChecking().

◆ needsChecking() [2/2]

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 724 of file LoopAccessAnalysis.cpp.

References llvm::RuntimePointerChecking::PointerInfo::AliasSetId, llvm::RuntimePointerChecking::PointerInfo::DependencySetId, I, llvm::RuntimePointerChecking::PointerInfo::IsWritePtr, and Pointers.

◆ print()

void RuntimePointerChecking::print ( raw_ostream & OS,
unsigned Depth = 0 ) const

Print the list run-time memory checks necessary.

Definition at line 768 of file LoopAccessAnalysis.cpp.

References CheckingGroups, llvm::Depth, getPtrToIdxMap(), llvm::raw_ostream::indent(), Pointers, and printChecks().

◆ printChecks()

void RuntimePointerChecking::printChecks ( raw_ostream & OS,
const SmallVectorImpl< RuntimePointerCheck > & Checks,
unsigned Depth = 0 ) const

Print Checks.

Definition at line 749 of file LoopAccessAnalysis.cpp.

References CheckingGroups, llvm::Depth, llvm::First, getPtrToIdxMap(), llvm::raw_ostream::indent(), N, and Pointers.

Referenced by print().

◆ reset()

void llvm::RuntimePointerChecking::reset ( )
inline

Reset the state of the pointer runtime information.

Definition at line 541 of file LoopAccessAnalysis.h.

References CheckingGroups, Need, and Pointers.

◆ RuntimeCheckingPtrGroup

friend struct RuntimeCheckingPtrGroup
friend

Definition at line 504 of file LoopAccessAnalysis.h.

References RuntimeCheckingPtrGroup.

Referenced by needsChecking(), and RuntimeCheckingPtrGroup.

Member Data Documentation

◆ CheckingGroups

SmallVector<RuntimeCheckingPtrGroup, 2> llvm::RuntimePointerChecking::CheckingGroups

Holds a partitioning of pointers into "check groups".

Definition at line 609 of file LoopAccessAnalysis.h.

Referenced by llvm::LoopVersioning::prepareNoAliasMetadata(), print(), printChecks(), and reset().

◆ Need

bool llvm::RuntimePointerChecking::Need = false

This flag indicates if we need to add the runtime check.

Definition at line 603 of file LoopAccessAnalysis.h.

Referenced by reset().

◆ Pointers

SmallVector<PointerInfo, 2> llvm::RuntimePointerChecking::Pointers

Information about the pointers that may require checking.

Definition at line 606 of file LoopAccessAnalysis.h.

Referenced by llvm::RuntimeCheckingPtrGroup::addPointer(), empty(), getPointerInfo(), insert(), needsChecking(), print(), printChecks(), and reset().


The documentation for this class was generated from the following files: