[PATCH] D14363: [FunctionAttrs] Remove a loop, NFC refactor

Sanjoy Das via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 4 19:07:02 PST 2015


This revision was automatically updated to reflect the committed changes.
Closed by commit rL252141: [FunctionAttrs] Remove a loop, NFC refactor (authored by sanjoy).

Changed prior to commit:
  http://reviews.llvm.org/D14363?vs=39299&id=39306#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D14363

Files:
  llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp

Index: llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp
===================================================================
--- llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp
+++ llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp
@@ -321,23 +321,21 @@
       return true;
     }
 
-    bool Found = false;
-    Function::arg_iterator AI = F->arg_begin(), AE = F->arg_end();
-    for (CallSite::arg_iterator PI = CS.arg_begin(), PE = CS.arg_end();
-         PI != PE; ++PI, ++AI) {
-      if (AI == AE) {
-        assert(F->isVarArg() && "More params than args in non-varargs call");
-        Captured = true;
-        return true;
-      }
-      if (PI == U) {
-        Uses.push_back(&*AI);
-        Found = true;
-        break;
-      }
+    // Note: the callee and the two successor blocks *follow* the argument
+    // operands.  This means there is no need to adjust UseIndex to account for
+    // these.
+
+    unsigned UseIndex =
+        std::distance(const_cast<const Use *>(CS.arg_begin()), U);
+
+    assert(UseIndex < CS.arg_size() && "Non-argument use?");
+    if (UseIndex >= F->arg_size()) {
+      assert(F->isVarArg() && "More params than args in non-varargs call");
+      Captured = true;
+      return true;
     }
-    assert(Found && "Capturing call-site captured nothing?");
-    (void)Found;
+
+    Uses.push_back(std::next(F->arg_begin(), UseIndex));
     return false;
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14363.39306.patch
Type: text/x-patch
Size: 1402 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151105/e10af392/attachment.bin>


More information about the llvm-commits mailing list