|
LLVM
3.7.0
|
This class emits a version of the loop where run-time checks ensure that may-alias pointers can't overlap. More...
#include <LoopVersioning.h>
Public Member Functions | |
| LoopVersioning (const LoopAccessInfo &LAI, Loop *L, LoopInfo *LI, DominatorTree *DT, const SmallVector< int, 8 > *PtrToPartition=nullptr) | |
| bool | needsRuntimeChecks () const |
| Returns true if we need memchecks to disambiguate may-aliasing accesses. More... | |
| void | versionLoop (Pass *P) |
| Performs the CFG manipulation part of versioning the loop including the DominatorTree and LoopInfo updates. More... | |
| void | addPHINodes (const SmallVectorImpl< Instruction * > &DefsUsedOutside) |
| Adds the necessary PHI nodes for the versioned loops based on the loop-defined values used outside of the loop. More... | |
| Loop * | getVersionedLoop () |
| Returns the versioned loop. More... | |
| Loop * | getNonVersionedLoop () |
| Returns the fall-back loop. More... | |
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 32 of file LoopVersioning.h.
| LoopVersioning::LoopVersioning | ( | const LoopAccessInfo & | LAI, |
| Loop * | L, | ||
| LoopInfo * | LI, | ||
| DominatorTree * | DT, | ||
| const SmallVector< int, 8 > * | PtrToPartition = nullptr |
||
| ) |
Definition at line 25 of file LoopVersioning.cpp.
References llvm::LoopBase< N, M >::getExitBlock(), and llvm::LoopBase< N, M >::getLoopPreheader().
| void LoopVersioning::addPHINodes | ( | const SmallVectorImpl< Instruction * > & | DefsUsedOutside | ) |
Adds the necessary PHI nodes for the versioned loops based on the loop-defined values used outside of the loop.
This needs to be called after versionLoop if there are defs in the loop that are used outside the loop. FIXME: this should be invoked internally by versionLoop and made private.
Definition at line 77 of file LoopVersioning.cpp.
References llvm::BasicBlock::begin(), llvm::LoopBase< N, M >::contains(), llvm::PHINode::Create(), llvm::dyn_cast(), llvm::LoopBase< N, M >::getExitBlock(), llvm::LoopBase< N, M >::getExitingBlock(), I, llvm::User::replaceUsesOfWith(), and llvm::Value::users().
|
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.
|
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.
| bool LoopVersioning::needsRuntimeChecks | ( | ) | const |
Returns true if we need memchecks to disambiguate may-aliasing accesses.
Definition at line 34 of file LoopVersioning.cpp.
References llvm::LoopAccessInfo::getRuntimePointerChecking(), and llvm::RuntimePointerChecking::needsAnyChecking().
| void LoopVersioning::versionLoop | ( | Pass * | P | ) |
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 38 of file LoopVersioning.cpp.
References llvm::LoopAccessInfo::addRuntimeCheck(), llvm::DominatorTreeBase< N >::changeImmediateDominator(), llvm::cloneLoopWithPreheader(), llvm::BranchInst::Create(), llvm::Instruction::eraseFromParent(), llvm::LoopBase< N, M >::getExitBlock(), llvm::LoopBase< N, M >::getHeader(), llvm::LoopBase< N, M >::getLoopPreheader(), llvm::BasicBlock::getTerminator(), llvm::remapInstructionsInBlocks(), llvm::Value::setName(), and llvm::SplitBlock().
1.8.6