Non-deterministic behavior when using LoopInfo pass in LLVM


I’m having a little problem with passes that use LoopInfo. Their statistics aren’t the same when I execute the same pass multiple times in the same program.

After some investigation, I’ve found out that LoopInfo is the root of the problem.

I wrote a little pass that counts the loop headers (number of basic blocks for which LoopInfo.isLoopHeader(BB) is true). I’ve picked one of the programs in the LLVM test suite benchmarks and in three consecutive tests the number of loop headers was different.

Does anybody know if this behavior is correct? If so, I would like to know the logic behind this pass.


Raphael Ernani

P.S.: Here is the output (a similar variation occurs when I run my pass without -mem2reg, -instnamer, and -break-crit-edges):

raphael@ubuntu:~/llvm-3.3/projects/test-suite/SingleSource/Benchmarks/Stanford/Output$ opt -mem2reg -instnamer -break-crit-edges -load -my-counter -stats Oscar.linked.rbc -f >/dev/null

This should definitely not happen on the same bitcode using the same binaries and compile flags. Please file a bug and attach the bitcode if you can?