[LLVMdev] Getting the trip count of a loop

Prakash Prabhu prakash.prabhu at gmail.com
Sat Apr 26 10:56:24 PDT 2008


Hi,

I am trying to add a new loop pass in which I making a call to get the trip
count of the loop using

Value *TripCountValue = L->getTripCount()

However I am always getting NULL for TripCountValue (confirmed through gdb).
I am running this pass after the canonicalization of induction variables:

opt --debug-pass=Structure -stats -indvars -loop-rotate -my-loop-pass <
main.bc > main.unroll.s
Pass Arguments:  -domtree -loops -scalar-evolution -loopsimplify
-domfrontier -scalar-evolution -lcssa -indvars -loop-rotate -domfrontier
-scalar-evolution -lcssa -my-loop-pass -preverify -domtree -verify
Target Data Layout
  ModulePass Manager
    FunctionPass Manager
      Dominator Tree Construction
      Natural Loop Construction
      Scalar Evolution Analysis
--      Scalar Evolution Analysis
      Canonicalize natural loops
      Dominance Frontier Construction
      Scalar Evolution Analysis
      Loop Pass Manager
        Loop-Closed SSA Form Pass
        Canonicalize Induction Variables
--        Canonicalize Induction Variables
        Rotate Loops
--        Loop-Closed SSA Form Pass
--        Rotate Loops
--      Dominance Frontier Construction
--      Scalar Evolution Analysis
      Dominance Frontier Construction
      Scalar Evolution Analysis
      Loop Pass Manager
        Loop-Closed SSA Form Pass
*        <My Loop Pass>*
--       * <My Loop Pass>*
--        Loop-Closed SSA Form Pass
--      Natural Loop Construction
--      Canonicalize natural loops
--      Dominance Frontier Construction
--      Dominator Tree Construction
--      Scalar Evolution Analysis
      Preliminary module verification
      Dominator Tree Construction
      Module Verifier
--      Preliminary module verification
--      Dominator Tree Construction
--      Module Verifier
    Bitcode Writer
--    Bitcode Writer

I have two loops in my source program which have statically-determinable
bounds:

for (i=1; i < 99999; i++)
{
....
}

Is there anything else I should be doing before invoking the getTripCount()
method ?

thanks,
Prakash
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20080426/ed1e1b6f/attachment.html>


More information about the llvm-dev mailing list