Commit 6b8bd355 authored by Ken Thompson's avatar Ken Thompson

nonaddressable = functioncall

code gen error

SVN=121541
parent e92b7538
...@@ -22,6 +22,13 @@ cgen(Node *n, Node *res) ...@@ -22,6 +22,13 @@ cgen(Node *n, Node *res)
if(res == N || res->type == T) if(res == N || res->type == T)
fatal("cgen: res nil"); 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");
}
lno = dynlineno; lno = dynlineno;
if(n->op != ONAME) if(n->op != ONAME)
dynlineno = n->lineno; // for diagnostics dynlineno = n->lineno; // for diagnostics
...@@ -32,6 +39,14 @@ cgen(Node *n, Node *res) ...@@ -32,6 +39,14 @@ cgen(Node *n, Node *res)
} }
if(!res->addable) { if(!res->addable) {
if(n->ullman > res->ullman) {
regalloc(&n1, nr->type, res);
cgen(n, &n1);
cgen(&n1, res);
regfree(&n1);
return;
}
igen(res, &n1, N); igen(res, &n1, N);
cgen(n, &n1); cgen(n, &n1);
regfree(&n1); regfree(&n1);
......
...@@ -688,10 +688,15 @@ cgen_asop(Node *nl, Node *nr, int op) ...@@ -688,10 +688,15 @@ cgen_asop(Node *nl, Node *nr, int op)
Node n1, n2; Node n1, n2;
int a; int a;
// botch compare ullman numbers if(nr->ullman >= UINF && nl->ullman >= UINF) {
// and use temp for functions fatal("cgen_asop both sides call");
}
a = optoas(op, nl->type); a = optoas(op, nl->type);
if(nr->ullman > nl->ullman) {
fatal("gcgen_asopen");
}
regalloc(&n1, nl->type, N); regalloc(&n1, nl->type, N);
if(nl->addable) { if(nl->addable) {
cgen(nr, &n1); cgen(nr, &n1);
...@@ -815,5 +820,9 @@ cgen_as(Node *nl, Node *nr, int op) ...@@ -815,5 +820,9 @@ cgen_as(Node *nl, Node *nr, int op)
nr->addable = 1; nr->addable = 1;
ullmancalc(nr); ullmancalc(nr);
} }
if(nr->ullman >= UINF && nl->ullman >= UINF) {
fatal("cgen_as both sides call");
}
cgen(nr, nl); cgen(nr, nl);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment