[LoopDeletion] (cleanup, NFC) Stop passing around reference to a vector

that we know has exactly one element when all we are going to do is get
that one element out of it.

Instead, pass around that one element.

There are more simplifications to come in this code...

llvm-svn: 292273
This commit is contained in:
Chandler Carruth 2017-01-17 22:00:52 +00:00
parent 04a73879a8
commit bb7e4b46e9
2 changed files with 7 additions and 9 deletions

View File

@ -32,8 +32,7 @@ public:
private:
bool isLoopDead(Loop *L, ScalarEvolution &SE,
SmallVectorImpl<BasicBlock *> &ExitingBlocks,
SmallVectorImpl<BasicBlock *> &ExitBlocks, bool &Changed,
BasicBlock *Preheader);
BasicBlock *ExitBlock, bool &Changed, BasicBlock *Preheader);
};
}

View File

@ -34,10 +34,8 @@ STATISTIC(NumDeleted, "Number of loops deleted");
/// form.
bool LoopDeletionPass::isLoopDead(Loop *L, ScalarEvolution &SE,
SmallVectorImpl<BasicBlock *> &ExitingBlocks,
SmallVectorImpl<BasicBlock *> &ExitBlocks,
bool &Changed, BasicBlock *Preheader) {
BasicBlock *ExitBlock = ExitBlocks[0];
BasicBlock *ExitBlock, bool &Changed,
BasicBlock *Preheader) {
// Make sure that all PHI entries coming from the loop are loop invariant.
// Because the code is in LCSSA form, any values used outside of the loop
// must pass through a PHI in the exit block, meaning that this check is
@ -129,9 +127,11 @@ bool LoopDeletionPass::runImpl(Loop *L, DominatorTree &DT, ScalarEvolution &SE,
if (ExitBlocks.size() != 1)
return false;
BasicBlock *ExitBlock = ExitBlocks[0];
// Finally, we have to check that the loop really is dead.
bool Changed = false;
if (!isLoopDead(L, SE, ExitingBlocks, ExitBlocks, Changed, preheader))
if (!isLoopDead(L, SE, ExitingBlocks, ExitBlock, Changed, preheader))
return Changed;
// Don't remove loops for which we can't solve the trip count.
@ -142,8 +142,7 @@ bool LoopDeletionPass::runImpl(Loop *L, DominatorTree &DT, ScalarEvolution &SE,
// Now that we know the removal is safe, remove the loop by changing the
// branch from the preheader to go to the single exit block.
BasicBlock *ExitBlock = ExitBlocks[0];
//
// Because we're deleting a large chunk of code at once, the sequence in which
// we remove things is very important to avoid invalidation issues. Don't
// mess with this unless you have good reason and know what you're doing.