LLVM  6.0.0svn
Public Member Functions | List of all members
llvm::LoopVersioning Class Reference

This class emits a version of the loop where run-time checks ensure that may-alias pointers can't overlap. More...

#include "llvm/Transforms/Utils/LoopVersioning.h"

Public Member Functions

 LoopVersioning (const LoopAccessInfo &LAI, Loop *L, LoopInfo *LI, DominatorTree *DT, ScalarEvolution *SE, bool UseLAIChecks=true)
 Expects LoopAccessInfo, Loop, LoopInfo, DominatorTree as input. More...
 
void versionLoop ()
 Performs the CFG manipulation part of versioning the loop including the DominatorTree and LoopInfo updates. More...
 
void versionLoop (const SmallVectorImpl< Instruction *> &DefsUsedOutside)
 Same but if the client has already precomputed the set of values used outside the loop, this API will allows passing that. More...
 
LoopgetVersionedLoop ()
 Returns the versioned loop. More...
 
LoopgetNonVersionedLoop ()
 Returns the fall-back loop. More...
 
void setAliasChecks (SmallVector< RuntimePointerChecking::PointerCheck, 4 > Checks)
 Sets the runtime alias checks for versioning the loop. More...
 
void setSCEVChecks (SCEVUnionPredicate Check)
 Sets the runtime SCEV checks for versioning the loop. More...
 
void annotateLoopWithNoAlias ()
 Annotate memory instructions in the versioned loop with no-alias metadata based on the memchecks issued. More...
 
void prepareNoAliasMetadata ()
 Set up the aliasing scopes based on the memchecks. More...
 
void annotateInstWithNoAlias (Instruction *VersionedInst, const Instruction *OrigInst)
 Add the noalias annotations to VersionedInst. More...
 

Detailed Description

This class emits a version of the loop where run-time checks ensure that may-alias pointers can't overlap.

It currently only supports single-exit loops and assumes that the loop already has a preheader.

Definition at line 36 of file LoopVersioning.h.

Constructor & Destructor Documentation

◆ LoopVersioning()

LoopVersioning::LoopVersioning ( const LoopAccessInfo LAI,
Loop L,
LoopInfo LI,
DominatorTree DT,
ScalarEvolution SE,
bool  UseLAIChecks = true 
)

Expects LoopAccessInfo, Loop, LoopInfo, DominatorTree as input.

It uses runtime check provided by the user. If UseLAIChecks is true, we will retain the default checks made by LAI. Otherwise, construct an object having no checks and we expect the user to add them.

Definition at line 33 of file LoopVersioning.cpp.

References assert(), llvm::RuntimePointerChecking::getChecks(), llvm::LoopBase< BlockT, LoopT >::getExitBlock(), llvm::LoopAccessInfo::getPSE(), llvm::LoopAccessInfo::getRuntimePointerChecking(), llvm::PredicatedScalarEvolution::getUnionPredicate(), llvm::Loop::isLoopSimplifyForm(), setAliasChecks(), and setSCEVChecks().

Member Function Documentation

◆ annotateInstWithNoAlias()

void LoopVersioning::annotateInstWithNoAlias ( Instruction VersionedInst,
const Instruction OrigInst 
)

◆ annotateLoopWithNoAlias()

void LoopVersioning::annotateLoopWithNoAlias ( )

Annotate memory instructions in the versioned loop with no-alias metadata based on the memchecks issued.

This is just wrapper that calls prepareNoAliasMetadata and annotateInstWithNoAlias on the instructions of the versioned loop.

Definition at line 207 of file LoopVersioning.cpp.

References annotateInstWithNoAlias(), AnnotateNoAlias, llvm::LoopAccessInfo::getDepChecker(), llvm::MemoryDepChecker::getMemoryInstructions(), I, and prepareNoAliasMetadata().

Referenced by annotateInstWithNoAlias(), and getNonVersionedLoop().

◆ getNonVersionedLoop()

Loop* llvm::LoopVersioning::getNonVersionedLoop ( )
inline

Returns the fall-back loop.

Control flows here if pointers in the loop may alias (i.e. one of the memchecks failed).

Definition at line 72 of file LoopVersioning.h.

References annotateInstWithNoAlias(), annotateLoopWithNoAlias(), Check(), I, prepareNoAliasMetadata(), setAliasChecks(), and setSCEVChecks().

Referenced by llvm::addStringMetadataToLoop().

◆ getVersionedLoop()

Loop* llvm::LoopVersioning::getVersionedLoop ( )
inline

Returns the versioned loop.

Control flows here if pointers in the loop don't alias (i.e. all memchecks passed). (This loop is actually the same as the original loop that we got constructed with.)

Definition at line 68 of file LoopVersioning.h.

Referenced by llvm::addStringMetadataToLoop().

◆ prepareNoAliasMetadata()

void LoopVersioning::prepareNoAliasMetadata ( )

◆ setAliasChecks()

void LoopVersioning::setAliasChecks ( SmallVector< RuntimePointerChecking::PointerCheck, 4 >  Checks)

Sets the runtime alias checks for versioning the loop.

Definition at line 46 of file LoopVersioning.cpp.

Referenced by getNonVersionedLoop(), isLoadConditional(), and LoopVersioning().

◆ setSCEVChecks()

void LoopVersioning::setSCEVChecks ( SCEVUnionPredicate  Check)

Sets the runtime SCEV checks for versioning the loop.

Definition at line 51 of file LoopVersioning.cpp.

Referenced by getNonVersionedLoop(), and LoopVersioning().

◆ versionLoop() [1/2]

void llvm::LoopVersioning::versionLoop ( )
inline

Performs the CFG manipulation part of versioning the loop including the DominatorTree and LoopInfo updates.

The loop that was used to construct the class will be the "versioned" loop i.e. the loop that will receive control if all the memchecks pass.

This allows the loop transform pass to operate on the same loop regardless of whether versioning was necessary or not:

for each loop L: analyze L if versioning is necessary version L transform L

Definition at line 59 of file LoopVersioning.h.

References llvm::findDefsUsedOutsideOfLoop(), and versionLoop().

Referenced by llvm::addStringMetadataToLoop(), annotateInstWithNoAlias(), and versionLoop().

◆ versionLoop() [2/2]

void LoopVersioning::versionLoop ( const SmallVectorImpl< Instruction *> &  DefsUsedOutside)

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