Unable to Get Induction Variable


I have a simple pass that prints the induction variable of each loop in a module, but it doesn’t work for the following C program:

void example() {

int array[100];

for (int i = 0; i < 100; i++) {

if (i % 2 == 0) {

array[i] = 2;


else {

array[i] = 1;




Calling the getInductionVariable() function returns nothing but i is clearly an induction variable in the above function.

I’m using the opt command with the following flags to run my pass:

-mem2reg -instnamer -lcssa -loop-rotate

Any suggestions on how to fix this issue would be appreciated.