28 : VersionedLoop(L), NonVersionedLoop(nullptr),
29 PtrToPartition(PtrToPartition), LAI(LAI), LI(LI), DT(DT) {
43 std::tie(FirstCheckInst, MemRuntimeCheck) =
45 assert(MemRuntimeCheck &&
"called even though needsAnyChecking = false");
48 MemCheckBB->
setName(VersionedLoop->
getHeader()->getName() +
".lver.memcheck");
62 LI, DT, NonVersionedLoopBlocks);
80 assert(PHIBlock &&
"No single successor to loop exit block");
82 for (
auto *Inst : DefsUsedOutside) {
83 auto *NonVersionedLoopInst = cast<Instruction>(VMap[Inst]);
89 assert(PN->getNumOperands() == 1 &&
90 "Exit block should only have on predecessor");
91 if (PN->getIncomingValue(0) == Inst)
99 if (!VersionedLoop->
contains(cast<Instruction>(
User)->getParent()))
104 PN->addIncoming(NonVersionedLoopInst, NonVersionedLoop->
getExitingBlock());
Pass interface - Implemented by all 'passes'.
iplist< Instruction >::iterator eraseFromParent()
eraseFromParent - This method unlinks 'this' from the containing basic block and deletes it...
LoopVersioning(const LoopAccessInfo &LAI, Loop *L, LoopInfo *LI, DominatorTree *DT, const SmallVector< int, 8 > *PtrToPartition=nullptr)
BasicBlock * SplitBlock(BasicBlock *Old, Instruction *SplitPt, DominatorTree *DT=nullptr, LoopInfo *LI=nullptr)
SplitBlock - Split the specified block at the specified instruction - every thing before SplitPt stay...
BlockT * getExitBlock() const
getExitBlock - If getExitBlocks would return exactly one block, return that block.
BlockT * getHeader() const
void remapInstructionsInBlocks(const SmallVectorImpl< BasicBlock * > &Blocks, ValueToValueMapTy &VMap)
Remaps instructions in Blocks using the mapping in VMap.
iterator begin()
Instruction iterator methods.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void setName(const Twine &Name)
Change the name of the value.
const RuntimePointerChecking * getRuntimePointerChecking() const
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
void versionLoop(Pass *P)
Performs the CFG manipulation part of versioning the loop including the DominatorTree and LoopInfo up...
void replaceUsesOfWith(Value *From, Value *To)
Replace uses of one Value with another.
BlockT * getLoopPreheader() const
getLoopPreheader - If there is a preheader for this loop, return it.
LLVM Basic Block Representation.
bool contains(const LoopT *L) const
contains - Return true if the specified loop is contained within in this loop.
BlockT * getExitingBlock() const
getExitingBlock - If getExitingBlocks would return exactly one block, return that block...
Drive the analysis of memory accesses in the loop.
static BranchInst * Create(BasicBlock *IfTrue, Instruction *InsertBefore=nullptr)
static PHINode * Create(Type *Ty, unsigned NumReservedValues, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Constructors - NumReservedValues is a hint for the number of incoming edges that this phi node will h...
bool needsAnyChecking(const SmallVectorImpl< int > *PtrPartition) const
Return true if any pointer requires run-time checking according to needsChecking. ...
iterator_range< user_iterator > users()
LLVM_ATTRIBUTE_UNUSED_RESULT std::enable_if< !is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Loop * cloneLoopWithPreheader(BasicBlock *Before, BasicBlock *LoopDomBB, Loop *OrigLoop, ValueToValueMapTy &VMap, const Twine &NameSuffix, LoopInfo *LI, DominatorTree *DT, SmallVectorImpl< BasicBlock * > &Blocks)
Clones a loop OrigLoop.
void addPHINodes(const SmallVectorImpl< Instruction * > &DefsUsedOutside)
Adds the necessary PHI nodes for the versioned loops based on the loop-defined values used outside of...
TerminatorInst * getTerminator()
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
void changeImmediateDominator(DomTreeNodeBase< NodeT > *N, DomTreeNodeBase< NodeT > *NewIDom)
changeImmediateDominator - This method is used to update the dominator tree information when a node's...
bool needsRuntimeChecks() const
Returns true if we need memchecks to disambiguate may-aliasing accesses.
std::pair< Instruction *, Instruction * > addRuntimeCheck(Instruction *Loc, const SmallVectorImpl< int > *PtrPartition=nullptr) const
Add code that checks at runtime if the accessed arrays overlap.