<div dir="ltr">Hello,<div><br></div><div style>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.</div><div style>

<br></div><div style>After some investigation, I've found out that LoopInfo is the root of the problem.</div><div style><br></div><div style>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.</div>

<div style><br></div><div style>Does anybody know if this behavior is correct? If so, I would like to know the logic behind this pass.</div><div style><br></div><div style>Thanks,</div><div style><br></div><div style>Raphael Ernani</div>

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

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

<div>                          ... Statistics Collected ...</div><div>===-------------------------------------------------------------------------===</div><div><br></div><div>12 NaturalLoopAnalysis - Number of Loop Headers</div>

<div> 8 break-crit-edges    - Number of blocks inserted</div><div>23 mem2reg             - Number of PHI nodes inserted</div><div>38 mem2reg             - Number of alloca's promoted</div><div>20 mem2reg             - Number of alloca's promoted with a single store</div>

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

<div>===-------------------------------------------------------------------------===</div><div>                          ... Statistics Collected ...</div><div>===-------------------------------------------------------------------------===</div>

<div><br></div><div>13 NaturalLoopAnalysis - Number of Loop Headers</div><div> 8 break-crit-edges    - Number of blocks inserted</div><div>23 mem2reg             - Number of PHI nodes inserted</div><div>38 mem2reg             - Number of alloca's promoted</div>

<div>20 mem2reg             - Number of alloca's promoted with a single store</div><div><br></div><div>raphael@ubuntu:~/llvm-3.3/projects/test-suite/SingleSource/Benchmarks/Stanford/Output$ opt -mem2reg -instnamer -break-crit-edges -load MyModule.so -my-counter -stats Oscar.linked.rbc -f >/dev/null</div>

<div>===-------------------------------------------------------------------------===</div><div>                          ... Statistics Collected ...</div><div>===-------------------------------------------------------------------------===</div>

<div><br></div><div>11 NaturalLoopAnalysis - Number of Loop Headers</div><div> 8 break-crit-edges    - Number of blocks inserted</div><div>23 mem2reg             - Number of PHI nodes inserted</div><div>38 mem2reg             - Number of alloca's promoted</div>

<div>20 mem2reg             - Number of alloca's promoted with a single store</div><div><br></div></div><div style><br></div></div>