plast-lab / doop

The official repo of Doop, the declarative pointer analysis framework.
http://plast-lab.github.io/
Other
164 stars 22 forks source link

Failed to enable soot optimization in soot-fact-generator #6

Open chennbnbnb opened 1 year ago

chennbnbnb commented 1 year ago

Hi, I want to enable soot soot optimization for dead code elimination, so I insert some code into org.clyze.doop.soot.Main.produceFacts(), But after running, it is found that the generated fact has not been optimized, and dead code still exists

image

here is my test case

public class A {

    public static String source() {
        return new String();
    }

    public static void sink(String var) {
        ; 
    }

    public static void main(String[] args) throws Exception {    
        String str = source();
        String bar;
        int x = 123;
        if (x==456){
            bar = str;
        }else{
            bar = "XXX";
        }
        sink(bar);
    }
}

if I directly run soot with cmd soot -f S -pp -cp . A -optimize, the shimple which soot generated is optimized:

public class A extends java.lang.Object
{

   ...

    public static void main(java.lang.String[]) throws java.lang.Exception
    {
        java.lang.String[] r0;
        java.lang.String r1, r1_1, r1_2;

        r0 := @parameter0: java.lang.String[];

        goto label1;

        r1 = staticinvoke <A: java.lang.String source()>();

        goto label2;

     label1:
        r1_1 = "XXX";

     label2:
        r1_2 = "XXX";

        staticinvoke <A: void sink(java.lang.String)>("XXX");

        return;
    }
}

I don't why those pack setting don't work in doop