Commit b0283611 authored by Ken Thompson's avatar Ken Thompson

fix issue 798

cannot allocate an audomatic temp
while real registers are allocated.
there is a chance that the automatic
will be allocated to one of the
allocated registers. the fix is to
not registerize such variables.

R=rsc
CC=golang-dev
https://golang.org/cl/1202042
parent 9192ec2e
......@@ -197,6 +197,12 @@ afunclit(Addr *a)
}
}
int32
anyregalloc(void)
{
return 0;
}
/*
* allocate register of type t, leave in n.
* if o != N, o is desired fixed register.
......
......@@ -28,6 +28,7 @@ struct Addr
uchar index;
uchar etype;
uchar scale; /* doubles as width in DATA op */
uchar pun; /* dont register variable */
};
#define A ((Addr*)0)
......
......@@ -238,6 +238,23 @@ gclean(void)
yyerror("reg %R left allocated\n", i);
}
int32
anyregalloc(void)
{
int i, j;
for(i=D_AL; i<=D_DI; i++) {
if(reg[i] == 0)
goto ok;
for(j=0; j<nelem(resvd); j++)
if(resvd[j] == i)
goto ok;
return 1;
ok:;
}
return 0;
}
/*
* allocate register of type t, leave in n.
* if o != N, o is desired fixed register.
......@@ -982,6 +999,7 @@ naddr(Node *n, Addr *a, int canemitcode)
a->width = n->type->width;
a->gotype = ngotype(n);
}
a->pun = n->pun;
a->offset = n->xoffset;
a->sym = n->sym;
if(a->sym == S)
......
......@@ -879,6 +879,8 @@ mkvar(Reg *r, Adr *a)
}
}
}
if(a->pun)
flag = 1;
switch(et) {
case 0:
......
......@@ -30,6 +30,7 @@ struct Addr
uchar index;
uchar etype;
uchar scale; /* doubles as width in DATA op */
uchar pun; /* dont register variable */
};
#define A ((Addr*)0)
......
......@@ -710,6 +710,23 @@ gclean(void)
yyerror("reg %R left allocated at %lux", i, regpc[i]);
}
int32
anyregalloc(void)
{
int i, j;
for(i=D_AL; i<=D_DI; i++) {
if(reg[i] == 0)
goto ok;
for(j=0; j<nelem(resvd); j++)
if(resvd[j] == i)
goto ok;
return 1;
ok:;
}
return 0;
}
/*
* allocate register of type t, leave in n.
* if o != N, o is desired fixed register.
......@@ -1692,6 +1709,7 @@ naddr(Node *n, Addr *a, int canemitcode)
a->width = n->type->width;
a->gotype = ngotype(n);
}
a->pun = n->pun;
a->offset = n->xoffset;
a->sym = n->sym;
if(a->sym == S)
......
......@@ -794,6 +794,8 @@ mkvar(Reg *r, Adr *a)
}
}
}
if(a->pun)
flag = 1;
switch(et) {
case 0:
......
......@@ -663,4 +663,5 @@ tempname(Node *n, Type *t)
stksize += w;
stksize = rnd(stksize, w);
n->xoffset = -stksize;
n->pun = anyregalloc();
}
......@@ -215,6 +215,7 @@ struct Node
uchar used;
uchar oldref;
uchar isddd;
uchar pun; // dont registerize variable ONAME
// most nodes
Node* left;
......@@ -1241,3 +1242,4 @@ int duintptr(Sym *s, int off, uint64 v);
int duintxx(Sym *s, int off, uint64 v, int wid);
void genembedtramp(Type*, Type*, Sym*);
int gen_as_init(Node*);
int anyregalloc();
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