[Soot-list] Bug in shimple transformation ?

Navindra Umanee navindra at cs.mcgill.ca
Tue Oct 25 00:46:28 EDT 2005


Hi Guillaume,

Sorry again for my tardiness.  Please try this patch:

--- soot/toolkits/scalar/GuaranteedDefs.java    (revision 2167)
+++ soot/toolkits/scalar/GuaranteedDefs.java    (revision 2168)
@@ -79,26 +79,24 @@
     GuaranteedDefsAnalysis(UnitGraph graph)
     {
         super(graph);
+        DominatorsFinder df = new SimpleDominatorsFinder(graph);
+        unitToGenerateSet = new HashMap(graph.size() * 2 + 1, 0.7f);

         // pre-compute generate sets
-        {
-            unitToGenerateSet = new HashMap(graph.size() * 2 + 1, 0.7f);
-            Iterator unitIt = graph.iterator();
-
-            while(unitIt.hasNext()){
-                Unit s = (Unit) unitIt.next();
-                FlowSet genSet = (FlowSet) emptySet.clone();
-                Iterator boxIt = s.getDefBoxes().iterator();
-
-                while(boxIt.hasNext()){
+        for(Iterator unitIt = graph.iterator(); unitIt.hasNext();){
+            Unit s = (Unit) unitIt.next();
+            FlowSet genSet = (FlowSet) emptySet.clone();
+
+            for(Iterator domsIt = df.getDominators(s).iterator(); domsIt.hasNext();){
+                Unit dom = (Unit) domsIt.next();
+                for(Iterator boxIt = dom.getDefBoxes().iterator(); boxIt.hasNext();){
                     ValueBox box = (ValueBox) boxIt.next();
-
                     if(box.getValue() instanceof Local)
                         genSet.add(box.getValue(), genSet);
                 }
-
-                unitToGenerateSet.put(s, genSet);
             }
+
+            unitToGenerateSet.put(s, genSet);
         }

         doAnalysis();
----------------------------------------------------

You can get the file directly from Soot trunk revision 2168.  Might
not be the most efficient solution but hopefully it's (more) correct
than before.

Sorry for the inconvenience.

Thanks,
Navin.

Navindra Umanee <navindra at cs.mcgill.ca> wrote:
> Hi Guillaume,
> 
> So sorry for the delay.  I have tracked this down to a problem with
> the GuaranteedDefs analysis that Shimple uses.  I'll look into fixing
> or re-implementing GuaranteedDefs later tonight.
> 
> Thanks,
> Navin.
> 
> Guillaume Salagnac <guillaume.salagnac at imag.fr> wrote:
> > I use Soot to perform some pointer analyses on programs in Shimple 
> > (SSA) form.  However, it seems that there is a bug in the Shimple 
> > translation pack. For the attached program (Test38), the local variable 
> > 'b' is split into 'b' and 'b_1' during the loop, but the 'c=b' 
> > affectation is not affected, thus producing wrong results when analysing 
> > the code.
> > 
> > 
> > For Clarity, I generated the Shimple using "java soot.Main -p jb 
> > use-original-names:true -f S toy.Test38", but the problem remains the 
> > same without this option.
> > 
> > 
> > Is it a bug in the Shimple transformer, or am I doing something wrong ?
> > 
> > Thanks in advance,
> > -G
> > 
> > 
> > 
> > -- 
> > Guillaume Salagnac
> > PhD Student, Laboratoire Vérimag, Grenoble.
> > Je sers la science et c'est ma joie.
> 
> 
> 
> > public class toy.Test38 extends java.lang.Object
> > {
> > 
> >     public void <init>()
> >     {
> >         toy.Test38 r0;
> > 
> >         r0 := @this: toy.Test38;
> >         specialinvoke r0.<java.lang.Object: void <init>()>();
> >         return;
> >     }
> > 
> >     public static void main(java.lang.String[])
> >     {
> >         java.lang.String[] r0;
> >         java.lang.Object[] r1;
> >         java.lang.Object r2, $r3, r4, r2_1;
> >         int i0, i1, i0_1, i0_2, i1_1, i1_2;
> > 
> >         r0 := @parameter0: java.lang.String[];
> >         r1 = newarray (java.lang.Object)[30];
> >         r2 = null;
> > (0)     i0 = 0;
> > 
> >      label0:
> >         i0_1 = Phi(i0 #0, i0_2 #1);
> >         if i0_1 >= 30 goto label1;
> > 
> >         $r3 = new java.lang.Object;
> >         specialinvoke $r3.<java.lang.Object: void <init>()>();
> >         r1[i0_1] = $r3;
> >         i0_2 = i0_1 + 1;
> > (1)     goto label0;
> > 
> >      label1:
> > (2)     i1 = 0;
> > 
> >      label2:
> >         i1_1 = Phi(i1 #2, i1_2 #3);
> >         if i1_1 >= 10 goto label3;
> > 
> >         r2_1 = r1[i1_1];
> >         i1_2 = i1_1 + 1;
> > (3)     goto label2;
> > 
> >      label3:
> >         r4 = r2;
> >         return;
> >     }
> > }
> > 
> > _______________________________________________
> > Soot-list mailing list
> > Soot-list at sable.mcgill.ca
> > http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
> 
> _______________________________________________
> Soot-list mailing list
> Soot-list at sable.mcgill.ca
> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list


More information about the Soot-list mailing list