[Soot-list] Why create temp$xx variables?

Eric Bodden eric.bodden at mail.mcgill.ca
Tue Apr 21 08:32:59 EDT 2009


Hi Peng.

I think this is just due to the naive way in which Soot generates the
code. If you simply apply a copy propagator or constant folder then
this should get rid of most of the variables in your example.

Eric

2009/4/21 Peng Du <imdupeng at gmail.com>:
> Hello, experts
>
> I have a newbie question about SOOT's IRs. Specifically, I have a simple
> test program
> on which I want to do some forward analysis via the Shimple IR. But I found
> SOOT
> would generate many temporary variables named "temp$XX", for each number
> literal (e.g. 2, 3), and intermediate results. This was the case for both
> Jimple and
> Shimple. I know Jimple is 3-address based, but all the expressions involve
> AT MOST
> three variables as you can see in the program.
>
> I wonder: Why is that?  Why we need those temp$ stuff? Can I eliminate that
> without
> turning on any optimizations or transformations? (I don't need them)  If
> yes, how?
>
> Thank you for looking.
>
>
> Peng Du
>
>
> Test program:
> ===========================================================
>     public static int foo(boolean flag){
>         int x, y, z;
>         if (flag){
>             x = 2; y = 3;
>         }
>         else {
>             x = 3; y = 2;
>         }
>         z = x + y;
>         return z;
>     }
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Jimple
> ===========================================================
>     public static int foo(boolean)
>     {
>         boolean flag;
>         int x, y, z, temp$0, temp$1, temp$2, temp$3, temp$4, temp$5;
>
>         flag := @parameter0: boolean;
>         if flag == 0 goto label1;
>
>         goto label0;
>
>      label0:
>         nop;
>         temp$0 = 2;
>         x = temp$0;
>         temp$1 = 3;
>         y = temp$1;
>         goto label2;
>
>      label1:
>         nop;
>         temp$2 = 3;
>         x = temp$2;
>         temp$3 = 2;
>         y = temp$3;
>
>      label2:
>         nop;
>         temp$4 = x;
>         temp$5 = temp$4 + y;
>         z = temp$5;
>         return z;
>     }
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> _______________________________________________
> Soot-list mailing list
> Soot-list at sable.mcgill.ca
> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
>
>



-- 
Eric Bodden
Sable Research Group, McGill University
Montréal, Québec, Canada


More information about the Soot-list mailing list