]> granicus.if.org Git - llvm/commitdiff
[LoopDeletion] (cleanup, NFC) Stop passing around reference to a vector
authorChandler Carruth <chandlerc@gmail.com>
Tue, 17 Jan 2017 22:00:52 +0000 (22:00 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Tue, 17 Jan 2017 22:00:52 +0000 (22:00 +0000)
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

include/llvm/Transforms/Scalar/LoopDeletion.h
lib/Transforms/Scalar/LoopDeletion.cpp

index 2501f5807b99ce403541ff9de1471b63ebf366c9..a2ebf9dac945aee3f35e31ff9e87cbbd8dd1ca87 100644 (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);
 };
 }
 
index 5a4c8448c53c564193ed2a94ed862eec3e426472..5d9ff3d662097ee29e91721910d72527c52a9de5 100644 (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.