class LoopVersioning
Declaration
class LoopVersioning { /* full declaration omitted */ };
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.
Declared at: llvm/include/llvm/Transforms/Utils/LoopVersioning.h:35
Method Overview
- public LoopVersioning(const llvm::LoopAccessInfo & LAI, llvm::Loop * L, llvm::LoopInfo * LI, llvm::DominatorTree * DT, llvm::ScalarEvolution * SE, bool UseLAIChecks = true)
- public void annotateInstWithNoAlias(llvm::Instruction * VersionedInst, const llvm::Instruction * OrigInst)
- public void annotateLoopWithNoAlias()
- public llvm::Loop * getNonVersionedLoop()
- public llvm::Loop * getVersionedLoop()
- public void prepareNoAliasMetadata()
- public void setAliasChecks(SmallVector<RuntimePointerChecking::PointerCheck, 4> Checks)
- public void setSCEVChecks(llvm::SCEVUnionPredicate Check)
- public void versionLoop()
- public void versionLoop(const SmallVectorImpl<llvm::Instruction *> & DefsUsedOutside)
Methods
¶LoopVersioning(const llvm::LoopAccessInfo& LAI,
llvm::Loop* L,
llvm::LoopInfo* LI,
llvm::DominatorTree* DT,
llvm::ScalarEvolution* SE,
bool UseLAIChecks = true)
LoopVersioning(const llvm::LoopAccessInfo& LAI,
llvm::Loop* L,
llvm::LoopInfo* LI,
llvm::DominatorTree* DT,
llvm::ScalarEvolution* SE,
bool UseLAIChecks = true)
Description
Expects LoopAccessInfo, Loop, LoopInfo, DominatorTree as input. It uses runtime check provided by the user. If \p 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.
Declared at: llvm/include/llvm/Transforms/Utils/LoopVersioning.h:41
Parameters
- const llvm::LoopAccessInfo& LAI
- llvm::Loop* L
- llvm::LoopInfo* LI
- llvm::DominatorTree* DT
- llvm::ScalarEvolution* SE
- bool UseLAIChecks = true
¶void annotateInstWithNoAlias(
llvm::Instruction* VersionedInst,
const llvm::Instruction* OrigInst)
void annotateInstWithNoAlias(
llvm::Instruction* VersionedInst,
const llvm::Instruction* OrigInst)
Description
Add the noalias annotations to \p VersionedInst. \p OrigInst is the instruction corresponding to \p VersionedInst in the original loop. Initialize the aliasing scopes with prepareNoAliasMetadata once before this can be called.
Declared at: llvm/include/llvm/Transforms/Utils/LoopVersioning.h:96
Parameters
- llvm::Instruction* VersionedInst
- const llvm::Instruction* OrigInst
¶void annotateLoopWithNoAlias()
void annotateLoopWithNoAlias()
Description
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.
Declared at: llvm/include/llvm/Transforms/Utils/LoopVersioning.h:85
¶llvm::Loop* getNonVersionedLoop()
llvm::Loop* getNonVersionedLoop()
Description
Returns the fall-back loop. Control flows here if pointers in the loop may alias (i.e. one of the memchecks failed).
Declared at: llvm/include/llvm/Transforms/Utils/LoopVersioning.h:71
¶llvm::Loop* getVersionedLoop()
llvm::Loop* getVersionedLoop()
Description
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.)
Declared at: llvm/include/llvm/Transforms/Utils/LoopVersioning.h:67
¶void prepareNoAliasMetadata()
void prepareNoAliasMetadata()
Description
Set up the aliasing scopes based on the memchecks. This needs to be called before the first call to annotateInstWithNoAlias.
Declared at: llvm/include/llvm/Transforms/Utils/LoopVersioning.h:89
¶void setAliasChecks(
SmallVector<
RuntimePointerChecking::PointerCheck,
4> Checks)
void setAliasChecks(
SmallVector<
RuntimePointerChecking::PointerCheck,
4> Checks)
Description
Sets the runtime alias checks for versioning the loop.
Declared at: llvm/include/llvm/Transforms/Utils/LoopVersioning.h:74
Parameters
- SmallVector<RuntimePointerChecking::PointerCheck, 4> Checks
¶void setSCEVChecks(llvm::SCEVUnionPredicate Check)
void setSCEVChecks(llvm::SCEVUnionPredicate Check)
Description
Sets the runtime SCEV checks for versioning the loop.
Declared at: llvm/include/llvm/Transforms/Utils/LoopVersioning.h:78
Parameters
- llvm::SCEVUnionPredicate Check
¶void versionLoop()
void versionLoop()
Description
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
Declared at: llvm/include/llvm/Transforms/Utils/LoopVersioning.h:58
¶void versionLoop(
const SmallVectorImpl<llvm::Instruction*>&
DefsUsedOutside)
void versionLoop(
const SmallVectorImpl<llvm::Instruction*>&
DefsUsedOutside)
Description
Same but if the client has already precomputed the set of values used outside the loop, this API will allows passing that.
Declared at: llvm/include/llvm/Transforms/Utils/LoopVersioning.h:62
Parameters
- const SmallVectorImpl<llvm::Instruction*>& DefsUsedOutside