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

Chandler Carruth via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 17 14:00:52 PST 2017


Author: chandlerc
Date: Tue Jan 17 16:00:52 2017
New Revision: 292273

URL: http://llvm.org/viewvc/llvm-project?rev=292273&view=rev
Log:
[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...

Modified:
    llvm/trunk/include/llvm/Transforms/Scalar/LoopDeletion.h
    llvm/trunk/lib/Transforms/Scalar/LoopDeletion.cpp

Modified: llvm/trunk/include/llvm/Transforms/Scalar/LoopDeletion.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Scalar/LoopDeletion.h?rev=292273&r1=292272&r2=292273&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Transforms/Scalar/LoopDeletion.h (original)
+++ llvm/trunk/include/llvm/Transforms/Scalar/LoopDeletion.h Tue Jan 17 16:00:52 2017
@@ -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);
 };
 }
 

Modified: llvm/trunk/lib/Transforms/Scalar/LoopDeletion.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopDeletion.cpp?rev=292273&r1=292272&r2=292273&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopDeletion.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopDeletion.cpp Tue Jan 17 16:00:52 2017
@@ -34,10 +34,8 @@ STATISTIC(NumDeleted, "Number of loops d
 /// 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,
   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,
 
   // 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.




More information about the llvm-commits mailing list