]> Cypherpunks repositories - gostls13.git/commitdiff
bug miscalculating ullman
authorKen Thompson <ken@golang.org>
Tue, 24 Jun 2008 17:30:33 +0000 (10:30 -0700)
committerKen Thompson <ken@golang.org>
Tue, 24 Jun 2008 17:30:33 +0000 (10:30 -0700)
in CALLMETH/DOTMETH

SVN=124321

src/cmd/6g/cgen.c
src/cmd/6g/gen.c
src/cmd/gc/subr.c
src/cmd/gc/walk.c

index 58b3af7059000cbb186d15e5eb24696b146f9eeb..9f3fa92e57e9ba8675a6a4fb789f95b94f7c8d9b 100644 (file)
@@ -19,20 +19,23 @@ cgen(Node *n, Node *res)
        }
        if(n == N || n->type == T)
                return;
+
+       lno = dynlineno;
+       if(n->op != ONAME)
+               dynlineno = n->lineno;  // for diagnostics
+
        if(res == N || res->type == T)
                fatal("cgen: res nil");
 
        if(n->ullman >= UINF) {
                if(n->op == OINDREG)
                        fatal("cgen: this is going to misscompile");
-               if(res->ullman >= UINF)
-                       fatal("cgen: fun both sides");
+               if(res->ullman >= UINF) {
+                       dump("fncalls", n);
+                       fatal("cgen: node and result functions");
+               }
        }
 
-       lno = dynlineno;
-       if(n->op != ONAME)
-               dynlineno = n->lineno;  // for diagnostics
-
        if(isfat(n->type)) {
                sgen(n, res, n->type->width);
                goto ret;
@@ -62,6 +65,7 @@ cgen(Node *n, Node *res)
        nr = n->right;
        if(nl != N && nl->ullman >= UINF)
        if(nr != N && nr->ullman >= UINF) {
+               dump("fncalls", n);
                fatal("cgen: both sides functions");
                goto ret;
        }
index 576db49a6f439a2f8b2d3255cf9d28415a795bcf..923c3a721bd0ff910072be1cccdca30c2297daae 100644 (file)
@@ -658,7 +658,7 @@ cgen_callret(Node *n, Node *res)
 
        fp = structfirst(&flist, getoutarg(t));
        if(fp == T)
-               fatal("cgen_aret: nil");
+               fatal("cgen_callret: nil");
 
        memset(&nod, 0, sizeof(nod));
        nod.op = OINDREG;
@@ -677,16 +677,14 @@ cgen_aret(Node *n, Node *res)
        Type *fp, *t;
        Iter flist;
 
-fatal("cgen_aret");
-
        t = n->left->type;
-       if(t->etype == TPTR32 || t->etype == TPTR64)
+       if(isptr[t->etype])
                t = t->type;
 
        fp = structfirst(&flist, getoutarg(t));
        if(fp == T)
                fatal("cgen_aret: nil");
-/* gins LEA */
+
        memset(&nod1, 0, sizeof(nod1));
        nod1.op = OINDREG;
        nod1.val.vval = D_SP;
index 3cd96fa525f9a225db633d617c8c9d4380ddaf42..5c8224bdc477132b4a1ec11a476b1fa37ffa895b 100644 (file)
@@ -1516,6 +1516,8 @@ ullmancalc(Node *n)
        case OI2S:
        case OI2I:
        case OCALL:
+       case OCALLMETH:
+       case OCALLINTER:
                ul = UINF;
                goto out;
        }
index 07f084fe5bed84e60759c8371f6b775c844b0abc..5948a6b1e064d09faea58cbf0dd597a614081126 100644 (file)
@@ -76,7 +76,6 @@ loop:
                if(top != Erv)
                        goto nottop;
                n->addable = 1;
-               ullmancalc(n);
                goto ret;
 
        case ONONAME:
@@ -94,7 +93,6 @@ loop:
                if(top == Etop)
                        goto nottop;
                n->addable = 1;
-               ullmancalc(n);
                if(n->type == T) {
                        s = n->sym;
                        if(s->undef == 0) {
@@ -163,14 +161,12 @@ loop:
                if(top == Elv)
                        goto nottop;
 
-               n->ullman = UINF;
                if(n->type != T)
                        goto ret;
 
                walktype(n->left, Erv);
                if(n->left == N)
                        goto ret;
-
                t = n->left->type;
                if(t == T)
                        goto ret;
@@ -210,14 +206,12 @@ loop:
                        break;
 
                case OCALLMETH:
-                       // add this-pointer to the arg list
-                       // this is bad - if not a simple
-                       // should make a temp copy rather
-                       // than recalculate it.
                        l = ascompatte(n->op, getinarg(t), &n->right, 0);
                        r = ascompatte(n->op, getthis(t), &n->left->left, 0);
                        if(l != N)
                                r = nod(OLIST, r, l);
+                       n->left->left = N;
+                       ullmancalc(n->left);
                        n->right = reorder1(r);
                        break;
                }
@@ -442,7 +436,6 @@ loop:
                if(n->left == N)
                        goto ret;
                evconst(n);
-               ullmancalc(n);
                if(n->op == OLITERAL)
                        goto ret;
                break;