shithub: mc

Download patch

ref: cd2bb9016e9aaa3ccf69e17a206d5a25ac1fd6f1
parent: 87c65208dece48a6d6005a221437bef879c65850
author: Ori Bernstein <[email protected]>
date: Fri Jun 15 09:52:26 EDT 2012

Correctly generate slice moves.

--- a/8/isel.c
+++ b/8/isel.c
@@ -739,6 +739,7 @@
         is.curbb = is.bb[j];
         for (i = 0; i < fn->cfg->bb[j]->nnl; i++) {
             isel(&is, fn->cfg->bb[j]->nl[i]);
+            //g(&is, Ilbl, locstrlbl("_"), NULL);
         }
     }
     is.curbb = is.bb[is.nbb - 1];
--- a/8/reduce.c
+++ b/8/reduce.c
@@ -374,17 +374,17 @@
 static Node *lowerslice(Simp *s, Node *n)
 {
     Node *t;
-    Node *base;
-    Node *len;
-    Node *stbase;
-    Node *stlen;
+    Node *base, *sz, *len;
+    Node *stbase, *stlen;
 
     t = temp(s, n);
-    /* base = (void*)base + off*sz */
+    /* *(&slice) = (void*)base + off*sz */
     base = slicebase(s, n->expr.args[0], n->expr.args[1]);
     len = mkexpr(-1, Osub, n->expr.args[2], n->expr.args[1], NULL);
     stbase = mkexpr(-1, Ostor, mkexpr(-1, Oaddr, t, NULL), base, NULL);
-    stlen = mkexpr(-1, Ostor, mkexpr(-1, Oaddr, mkexpr(-1, Oadd, t, ptrsz, NULL), NULL), len, NULL);
+    /* *(&slice + ptrsz) = len */
+    sz = mkexpr(-1, Oadd, mkexpr(-1, Oaddr, t, NULL), ptrsz, NULL);
+    stlen = mkexpr(-1, Ostor, sz, len, NULL);
     append(s, stbase);
     append(s, stlen);
     return t;