[PATCH] D68924: CodeExtractor: NFC: Use Range based loop

Aditya Kumar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 15 18:51:46 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rG9d10b9d99b4d: CodeExtractor: NFC: Use Range based loop (authored by hiraditya).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68924/new/

https://reviews.llvm.org/D68924

Files:
  llvm/lib/Transforms/Utils/CodeExtractor.cpp


Index: llvm/lib/Transforms/Utils/CodeExtractor.cpp
===================================================================
--- llvm/lib/Transforms/Utils/CodeExtractor.cpp
+++ llvm/lib/Transforms/Utils/CodeExtractor.cpp
@@ -961,12 +961,12 @@
   // within the new function. This must be done before we lose track of which
   // blocks were originally in the code region.
   std::vector<User *> Users(header->user_begin(), header->user_end());
-  for (unsigned i = 0, e = Users.size(); i != e; ++i)
+  for (auto &U : Users)
     // The BasicBlock which contains the branch is not in the region
     // modify the branch target to a new block
-    if (Instruction *I = dyn_cast<Instruction>(Users[i]))
-      if (I->isTerminator() && !Blocks.count(I->getParent()) &&
-          I->getParent()->getParent() == oldFunction)
+    if (Instruction *I = dyn_cast<Instruction>(U))
+      if (I->isTerminator() && I->getFunction() == oldFunction &&
+          !Blocks.count(I->getParent()))
         I->replaceUsesOfWith(header, newHeader);
 
   return newFunction;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68924.225145.patch
Type: text/x-patch
Size: 1050 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191016/dd37451b/attachment.bin>


More information about the llvm-commits mailing list