[Soot-list] Statements in Loop statements return by LoopFinder not in program order?

Patrick Meredith pmeredit at gmail.com
Fri Apr 6 04:28:12 EDT 2012


Hi all,

The following problem (?) occurs with between the classes
soot.jimple.toolkits.annotation.logic.Loop and soot.jimple.toolkits.
annotation.logic.LoopFinder.

The javadoc for Loop.getLoopStatements()  says:

"all statements of the loop, including the header; the header will be the
first element returned and then the other statements follow in the natural
ordering of the loop"

I assume that natural ordering of the loop would be the order the
statements appear, statically, in the program.

For simple examples that assumption held, but for this code:

    label0:
        $i1 = i0 & 1;
        if $i1 != 0 goto label1;

        $i2 = i0 * 15;
        staticinvoke <Test: void f(int)>($i2);
        goto label2;

     label1:
        staticinvoke <Test: void f(int)>(i0);

     label2:
        $i3 = i0 & 111;
        if $i3 != 34 goto label3;

        goto label4;

     label3:
        i0 = i0 + 1;
        goto label0;

I ended up with the following loop statements:


[$i1 = i0 & 1, $i2 = i0 * 15, staticinvoke <Test: void f(int)>($i2), goto
[?= $i3 = i0 & 111], if $i1 != 0 goto staticinvoke <Test: void f(int)>(i0),
staticinvoke <Test: void f(int)>(i0), $i3 = i0 & 111, if $i3 != 34 goto i0
= i0 + 1, i0 = i0 + 1, goto [?= $i1 = i0 & 1]]

The relevant issue here is that if $1 != 0 goto label1 is in the wrong
place.  I managed to get around this problem with a hack of dumping the
loop statements to a Set and checking statements in program order in the
body chain starting at the loop header for containment in the set, but this
is a rather ugly hack when it seems to me that the List<Stmt> returned by
Loop.getLoopStatements() should be in program order.  It also seems like a
violation of the Loop class's API.  Does anyone have any input on this?

Thanks,

-Patrick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20120406/9fb58ca2/attachment-0001.html 


More information about the Soot-list mailing list