[Soot-list] Statements in Loop statements return by LoopFinder not in program order?
pmeredit at gmail.com
Fri Apr 6 04:28:12 EDT 2012
The following problem (?) occurs with between the classes
soot.jimple.toolkits.annotation.logic.Loop and soot.jimple.toolkits.
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:
$i1 = i0 & 1;
if $i1 != 0 goto label1;
$i2 = i0 * 15;
staticinvoke <Test: void f(int)>($i2);
staticinvoke <Test: void f(int)>(i0);
$i3 = i0 & 111;
if $i3 != 34 goto label3;
i0 = i0 + 1;
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?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Soot-list