diff --git a/include/llvm/IR/Use.h b/include/llvm/IR/Use.h index 62586f5b3d8..37967f8c023 100644 --- a/include/llvm/IR/Use.h +++ b/include/llvm/IR/Use.h @@ -116,6 +116,9 @@ public: Use *getNext() const { return Next; } + /// \brief Return the operand # of this use in its User. + unsigned getOperandNo() const; + /// \brief Initializes the waymarking tags on an array of Uses. /// /// This sets up the array of Uses such that getUser() can find the User from @@ -208,9 +211,8 @@ public: Use &getUse() const { return *U; } /// \brief Return the operand # of this use in its User. - /// - /// Defined in User.h - unsigned getOperandNo() const; + /// FIXME: Replace all callers with a direct call to Use::getOperandNo. + unsigned getOperandNo() const { return U->getOperandNo(); } }; // Create wrappers for C Binding types (see CBindingWrapping.h). diff --git a/include/llvm/IR/User.h b/include/llvm/IR/User.h index 4f8d1b35df9..d288e1908c2 100644 --- a/include/llvm/IR/User.h +++ b/include/llvm/IR/User.h @@ -206,12 +206,6 @@ template<> struct simplify_type { } }; -// value_use_iterator::getOperandNo - Requires the definition of the User class. -template -unsigned value_use_iterator::getOperandNo() const { - return U - U->getUser()->op_begin(); -} - } // End llvm namespace #endif diff --git a/lib/IR/Use.cpp b/lib/IR/Use.cpp index 5f01e238e04..60a0c566889 100644 --- a/lib/IR/Use.cpp +++ b/lib/IR/Use.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// #include "llvm/IR/Use.h" +#include "llvm/IR/User.h" #include "llvm/IR/Value.h" #include @@ -44,6 +45,10 @@ User *Use::getUser() const { : reinterpret_cast(const_cast(End)); } +unsigned Use::getOperandNo() const { + return this - getUser()->op_begin(); +} + // Sets up the waymarking algoritm's tags for a series of Uses. See the // algorithm details here: //