[LLVMdev] Tell whether an llvm::BranchInst* may depend on the function parameters?

Zhoulai zell08v at gmail.com
Wed May 20 11:05:09 PDT 2015


Hi,

I have a naive question in using LLVM.

Given an llvm::Function*, and an llvm::BranchInst* of the function, is
their a simple, off-the-shelf procedure in LLVM for me to determine whether
there is dependency between the branch instruction and the function's input
parameters? For example:

*void foo(int n){*
*   i=0; *
*  if (i<=n){              //B1*
*       i++;*
*   }*
*  int j=0*
*  if (j<=2*j){            //B2*
*       j++;*
*  }*
*  if (i+j>=1){          //B3*
*      return;*
* }*
*return;*
*}*

Here, the first branch B1 depends on the input 'n'; the second branch B2
does not depends on 'n'; and the third B3 depends (indirectly) on input 'n'
as it uses 'i'.

Such static analysis can quickly become complicated, but maybe LLVM
provides a simple, conservative solution for us.   Can anyone tell me the
right LLVM API to use. A simple example of the use would be the most
helpful.

Thanks in advance.
Zhoulai
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150520/d330bda7/attachment.html>


More information about the llvm-dev mailing list