Changeset View
Changeset View
Standalone View
Standalone View
lib/Transforms/Utils/LoopVersioning.cpp
Show First 20 Lines • Show All 106 Lines • ▼ Show 20 Lines | void LoopVersioning::versionLoop( | ||||
remapInstructionsInBlocks(NonVersionedLoopBlocks, VMap); | remapInstructionsInBlocks(NonVersionedLoopBlocks, VMap); | ||||
// Insert the conditional branch based on the result of the memchecks. | // Insert the conditional branch based on the result of the memchecks. | ||||
Instruction *OrigTerm = RuntimeCheckBB->getTerminator(); | Instruction *OrigTerm = RuntimeCheckBB->getTerminator(); | ||||
BranchInst::Create(NonVersionedLoop->getLoopPreheader(), | BranchInst::Create(NonVersionedLoop->getLoopPreheader(), | ||||
VersionedLoop->getLoopPreheader(), RuntimeCheck, OrigTerm); | VersionedLoop->getLoopPreheader(), RuntimeCheck, OrigTerm); | ||||
OrigTerm->eraseFromParent(); | OrigTerm->eraseFromParent(); | ||||
// The loops merge in the original exit block. This is now dominated by the | // The loops merge in the original exit block. The exit block is now | ||||
// memchecking block. | // dominated by the memchecking block, if the exit block did not dominate | ||||
// the memchecking block initially. | |||||
if (!DT->dominates(VersionedLoop->getExitBlock(), RuntimeCheckBB)) | |||||
DT->changeImmediateDominator(VersionedLoop->getExitBlock(), RuntimeCheckBB); | DT->changeImmediateDominator(VersionedLoop->getExitBlock(), RuntimeCheckBB); | ||||
// Adds the necessary PHI nodes for the versioned loops based on the | // Adds the necessary PHI nodes for the versioned loops based on the | ||||
// loop-defined values used outside of the loop. | // loop-defined values used outside of the loop. | ||||
addPHINodes(DefsUsedOutside); | addPHINodes(DefsUsedOutside); | ||||
} | } | ||||
void LoopVersioning::addPHINodes( | void LoopVersioning::addPHINodes( | ||||
const SmallVectorImpl<Instruction *> &DefsUsedOutside) { | const SmallVectorImpl<Instruction *> &DefsUsedOutside) { | ||||
▲ Show 20 Lines • Show All 198 Lines • Show Last 20 Lines |