[Soot-list] Any suggestions to find the end of a loop?
Kelvin Tian
kevinn.tian at gmail.com
Fri Jul 31 11:23:41 EDT 2009
Hi Eric,
I've solved my problem through another way, by checking loop header.
Here's the Jimple code of function foo(). Thanks,
private static void foo()
{
int $i0, i1, $i2, $i3, $i4;
$i0 = <TestLoop: int calls>;
$i2 = $i0 + 1;
<TestLoop: int calls> = $i2;
i1 = 0;
label0:
if i1 >= 3 goto label1;
$i3 = <TestLoop: int loopcnt1>;
$i4 = $i3 + 1;
<TestLoop: int loopcnt1> = $i4;
staticinvoke <TestLoop: void bar()>();
i1 = i1 + 1;
goto label0;
label1:
staticinvoke <TestLoop: void bar1()>();
return;
}
--
Best regards,
Kelvin
On Thu, Jul 30, 2009 at 6:09 PM, Eric Bodden <eric.bodden at mail.mcgill.ca>wrote:
> Hi Kelvin.
>
> This seems odd to me. Can you post the whole Jimple body for this
> method, please?
>
> Eric
>
> 2009/7/29 Kelvin Tian <kevinn.tian at gmail.com>:
> > 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
> >
> >
>
>
>
> --
> 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/20090731/f1d26e0f/attachment-0001.html
More information about the Soot-list
mailing list