From: Chandler Carruth Date: Tue, 17 Jan 2017 22:00:52 +0000 (+0000) Subject: [LoopDeletion] (cleanup, NFC) Stop passing around reference to a vector X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=40d8cc12dd752776cefd64f4ab972a7493821ee6;p=llvm [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... git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292273 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Transforms/Scalar/LoopDeletion.h b/include/llvm/Transforms/Scalar/LoopDeletion.h index 2501f5807b9..a2ebf9dac94 100644 --- a/include/llvm/Transforms/Scalar/LoopDeletion.h +++ b/include/llvm/Transforms/Scalar/LoopDeletion.h @@ -32,8 +32,7 @@ public: private: bool isLoopDead(Loop *L, ScalarEvolution &SE, SmallVectorImpl &ExitingBlocks, - SmallVectorImpl &ExitBlocks, bool &Changed, - BasicBlock *Preheader); + BasicBlock *ExitBlock, bool &Changed, BasicBlock *Preheader); }; } diff --git a/lib/Transforms/Scalar/LoopDeletion.cpp b/lib/Transforms/Scalar/LoopDeletion.cpp index 5a4c8448c53..5d9ff3d6620 100644 --- a/lib/Transforms/Scalar/LoopDeletion.cpp +++ b/lib/Transforms/Scalar/LoopDeletion.cpp @@ -34,10 +34,8 @@ STATISTIC(NumDeleted, "Number of loops deleted"); /// form. bool LoopDeletionPass::isLoopDead(Loop *L, ScalarEvolution &SE, SmallVectorImpl &ExitingBlocks, - SmallVectorImpl &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.