[Soot-list] Constant propagation analysis in SOOT

Bernhard Berger berber at tzi.de
Tue Sep 10 01:37:05 EDT 2013


Hi Zhoulai,

what is the result you want to get? Just the fact that x in print(x) is constant in all cases or that x is definitely 3 (what would be your expected result in the case that y = 2 and z = 4)? Do you want this information intra procedural or inter procedural?

The ConstantPropagatorAndFolder works in a intra procedural way and propagates nuemric constants and calculates the result of expressions on numeric constants. I think the current implementation can be extended to a version that checks that all definitions of a use have the same constant value. If you change the code feel free to contribute the enhancements back to the soot community.

Regards,

Bernhard 

Am 10.09.2013 um 07:19 schrieb Zhoulai <zell08v at gmail.com>:

> Dear all,
> 
> I am about to use  a constant propagation/folder  analysis under Soot framework. It seems  that there exists  one such implementation in SOOT already:
> 
> soot.jimple.toolkits.scalar.ConstantPropagatorAndFolder
> 
> However,  this implementation seems to be naive.  If I understand correctly its source code, 
> 
> http://www.massapi.com/source/sootsrc-2.4.0/src/soot/jimple/toolkits/scalar/ConstantPropagatorAndFolder.java.html
> 
> the implementation associates with local variables a constant only if this  underlined variable has a single definition site.   For example, the implementation  cannot decide that 'x' is a constant  for the snippet below:
> 
> y=3; z=3; if (?) {x=y} else {x=z};
> print (x);
> 
> In my application, I need that 'x' be recognized as constant. Although this is not a difficult problem, I would try to avoid code duplication whenever possible. So would you please tell me whether Soot has built in a more sophisticated constant propagation analysis than its "ConstantPropagatorAndFolder" mentioned above, such as the conditional constant propagation?  Thanks in advance. 
> 
> Zhoulai (zell)
> 
> 
> 
> _______________________________________________
> Soot-list mailing list
> Soot-list at sable.mcgill.ca
> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20130910/4a4a5ca2/attachment.html 


More information about the Soot-list mailing list