Consider the following piece of code:
int main() {
int a = 0;
int b = 1;
for (int i = 0; i < 3; i++) {
a = 2;
int c = 1;
int d = 3;
d = a + c;
}
a = b+2;
}
In the piece of code above three variables have a lifespan contained in the body of the loop (i
, c
and d
). I would like to be able to count the variables whose lifespan exists in the body of any given loop using LLVM (i.e. for this loop, my code should return 3).
I found the Live Variables Analysis, but I'm having trouble using it to find what I described above.