bug miscalculating ullman

in CALLMETH/DOTMETH

SVN=124321
This commit is contained in:
Ken Thompson 2008-06-24 10:30:33 -07:00
parent d4c2da409b
commit 78c8dec944
4 changed files with 17 additions and 20 deletions

View 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;
}

View 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;

View file

@ -1516,6 +1516,8 @@ ullmancalc(Node *n)
case OI2S:
case OI2I:
case OCALL:
case OCALLMETH:
case OCALLINTER:
ul = UINF;
goto out;
}

View 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;