Is there a way in llvm that using static analysis, i can find out if one variable is a particular function of other variables?
Eg: As in a cuda program, i want to find out given a variable tid, does it store a global thread ID or not?
int tid = blockIdx.x * blockDim.x + threadId.x;
Edit: I am trying to figure if i can write a pass which analyzes the program and see if any divergence or array access is based on this global id alone and not on, other values like blockID or local threadId. I am trying to identify cases where changing the cuda program’s gridDim, blockDim doesn’t change the program output, like for instance a vector add, i can have gridDim as 128, blockDim as 4 or gridDim as 8, blockDim as 64. The output is not affected. Iam doing this in llvm because i am trying to use a compilation framework called ocelot which converts cuda to x86.
The closest I can find is the memdeps pass, but this is primarily about other operations on memory, which does not necessarily correspond to operations on “variables” in the usual sense – they may be in registers. It appears to be a reasonable standard dependence analysis problem, however, so perhaps you could modify this pass to your needs. The alias analysis passes might be helpful too, though not in the presence of operations that stop variables from aliasing one another (e.g., copies, arithmetic).
Incidentally, your question is rather under-specified. This is usually the kind of analysis (alias analysis, for example) that would make a lot more sense in the source language (cuda, for example), not in the target language (LLVM, for example).