[llvm-dev] [LLVMdev] Interprocedural use-def chains

Sanjoy Das via llvm-dev llvm-dev at lists.llvm.org
Tue Jul 26 14:51:51 PDT 2016


Hi Dounia,

Dounia Khaldi via llvm-dev wrote:
 > I have been using the USE class to access the use-def chains of
 > different values. However, what I have noticed is that the set of users
 > of a particular value is limited for the appearance of that variable in
 > the current function.
 >
 > How can I get the interprocedural use of a particular value? For
 > example, if a variable /a/ is used as an argument in a function call
 > /foo/, the USE analysis would go to the definition of/foo/, and get me
 > the users of that argument in the called function as well. Currently,
 > what USE does is that it returns the call as a use and stops there.

Why not just recurse to uses of the corresponding llvm::Argument
instance?  Is there a reason why you're avoiding that?  This won't
work for varargs, but that's a difficult problem anyway.

Specifically, I'm saying:

   if (user is CallInst or InvokeInst) {
     unsigned ArgNo = // Get argument no. of Use &
     if (auto *F = getCallTargetIfPossible()) {
       pushToWorklist(F->getArgument(ArgNo)->users()); // Or recurse
     }
   }

-- Sanjoy


More information about the llvm-dev mailing list