introduce a useful abstraction to find out if a Use is in the call position of an instruction

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62788 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Transforms/IPO/StructRetPromotion.cpp b/lib/Transforms/IPO/StructRetPromotion.cpp
index 00556f9..9f54388 100644
--- a/lib/Transforms/IPO/StructRetPromotion.cpp
+++ b/lib/Transforms/IPO/StructRetPromotion.cpp
@@ -149,14 +149,11 @@
        FnUseI != FnUseE; ++FnUseI) {
     // The function is passed in as an argument to (possibly) another function,
     // we can't change it!
-    if (FnUseI.getOperandNo() != 0)
-      return false;
-
     CallSite CS = CallSite::get(*FnUseI);
     Instruction *Call = CS.getInstruction();
     // The function is used by something else than a call or invoke instruction,
     // we can't change it!
-    if (!Call)
+    if (!Call || !CS.isCallee(FnUseI))
       return false;
     CallSite::arg_iterator AI = CS.arg_begin();
     Value *FirstArg = *AI;