[PATCH] D66844: getArgOperandNo helper function

Stefan Stipanovic via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 27 16:13:49 PDT 2019


sstefan1 created this revision.
sstefan1 added reviewers: jdoerfert, uenoku.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

A helper function to get argument number of a arg operand Use.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D66844

Files:
  llvm/include/llvm/IR/InstrTypes.h


Index: llvm/include/llvm/IR/InstrTypes.h
===================================================================
--- llvm/include/llvm/IR/InstrTypes.h
+++ llvm/include/llvm/IR/InstrTypes.h
@@ -1267,6 +1267,19 @@
     return isArgOperand(&UI.getUse());
   }
 
+  /// Given a use for a arg operand, get the arg operand number that
+  /// corresponds to it.
+  unsigned getArgOperandNo(const Use *U) const {
+    assert(isArgOperand(U) && "Arg operand # out of range!");
+    return U - arg_begin();
+  }
+
+  /// Given a value use iterator, return the arg operand number corresponding to
+  /// it. Iterator must actually correspond to a data operand.
+  unsigned getArgOperandNo(Value::const_user_iterator UI) const {
+    return getArgOperandNo(&UI.getUse());
+  }
+
   /// Returns true if this CallSite passes the given Value* as an argument to
   /// the called function.
   bool hasArgument(const Value *V) const {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66844.217525.patch
Type: text/x-patch
Size: 914 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190827/09229714/attachment.bin>


More information about the llvm-commits mailing list