[Soot-list] Any suggestions to find the end of a loop?

Kelvin Tian kevinn.tian at gmail.com
Wed Jul 29 12:09:13 EDT 2009


Dear Eric,

    Thanks for the reply.  I can find the end of loop now except one
scenario, which has a function call below the loop.  In the example code
below,  I found the loop header and its successors and post-dominator as
follows.

    private static void foo() {
        calls++;
        for (int i = 0; i < 3; i++)
           {
            loopcnt1++;
            bar();
        }

        bar1();
    }

loop header:   if i1 >= 3 goto staticinvoke <TestLoop: void bar1()>()
loop header's post-dominator:   [return, if i1 >= 3 goto staticinvoke
<TestLoop: void bar1()>()]
loop header's successor:    [$i3 = <TestLoop: int loopcnt1>, staticinvoke
<TestLoop: void bar1()>()]

So I see in Soot, the loop header connects two statements together, without
labels . The loop header's post-dominators include "return" and itself,
while don't include the statement "bar1()" after the loop because the loop
header already contains calling to "bar1()".  But the loop header's
successors include the original statement "bar1()" after the loop,  so in
this case I can't find the end of the loop.  So it seems loop header has two
different representations when getting its post-dominator and its
successors.  Is this conflict an original design or a possible bug? Are
there any suggestions? Thanks again for your help!


--
Best regards,
Kelvin



On Mon, Jul 27, 2009 at 3:45 PM, Eric Bodden <eric.bodden at mail.mcgill.ca>wrote:

> Hi Kelvin.
>
> I wound have done it the same way - sounds reasonable to me.
>
> Eric
>
> 2009/7/27 Kelvin Tian <kevinn.tian at gmail.com>:
> > I need to identify the end of a loop and to print out some profiling info
> > after a loop's execution.  One way I've got to identify the end of a loop
> is
> > to find the loop head, and iterate through its successors, as the
> statements
> > in loop body can't be the post-dominator of the loop head, so when I meet
> > with a statement which is a post dominator of the loop head,  then the
> end
> > of a loop is found.   Is this way applicable for Soot to implement or are
> > there any better suggestions?  Thanks for any suggestions!
> >
> >
> > --
> > Best regards,
> > Kelvin
> >
> >
> > _______________________________________________
> > Soot-list mailing list
> > Soot-list at sable.mcgill.ca
> > http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
> >
> >
>
>
>
> --
> Eric Bodden
> Software Technology Group
> Technical University Darmstadt, Germany
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20090729/7056ac69/attachment.html 


More information about the Soot-list mailing list