[llvm-dev] Unable to Get Induction Variable

Kyle Chen via llvm-dev llvm-dev at lists.llvm.org
Fri Aug 6 19:40:58 PDT 2021


Hi,

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.


Thanks,
Kyle


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210807/0d6399f7/attachment.html>


More information about the llvm-dev mailing list