[llvm-dev] Obtaining bounds of loops

bodhisatwa via llvm-dev llvm-dev at lists.llvm.org
Mon Feb 22 08:48:05 PST 2021


Hi,

I am trying to test out the getBounds() method from LoopInfo. However, the 
method doesn't seem to obtain the bounds of simple loops like -

        for (int j = 0; j < 10; j ++)
            B[j] = 6;

        int i = 10, j = 2,

        while ( i != j)
              j++;

  My code snippet in the function pass is as follows (which gives the output 
as "No value for loop bounds" for all the loops):

       LoopInfo &LI = getAnalysis<LoopInfoWrapperPass>().getLoopInfo();

       for (auto loop = LI.begin(), e = LI.end(); loop != e; ++loop )
       {
           ScalarEvolution *SE = 
&getAnalysis<ScalarEvolutionWrapperPass>().getSE();
           auto b = (*loop)->getBounds(*SE);

           if (!b.hasValue())
                {
                   errs() << "No value for loop bounds\n";
                }
       }

  Is there something that I am missing here?


  Thanks,
  Bodhi



More information about the llvm-dev mailing list