1
0
mirror of https://github.com/golang/go synced 2024-11-20 06:24:40 -07:00

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
This commit is contained in:
Ken Thompson 2010-05-20 17:31:28 -07:00
parent 9192ec2ea1
commit b0283611e4
9 changed files with 51 additions and 0 deletions

View File

@ -197,6 +197,12 @@ afunclit(Addr *a)
} }
} }
int32
anyregalloc(void)
{
return 0;
}
/* /*
* allocate register of type t, leave in n. * allocate register of type t, leave in n.
* if o != N, o is desired fixed register. * if o != N, o is desired fixed register.

View File

@ -28,6 +28,7 @@ struct Addr
uchar index; uchar index;
uchar etype; uchar etype;
uchar scale; /* doubles as width in DATA op */ uchar scale; /* doubles as width in DATA op */
uchar pun; /* dont register variable */
}; };
#define A ((Addr*)0) #define A ((Addr*)0)

View File

@ -238,6 +238,23 @@ gclean(void)
yyerror("reg %R left allocated\n", i); 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. * allocate register of type t, leave in n.
* if o != N, o is desired fixed register. * 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->width = n->type->width;
a->gotype = ngotype(n); a->gotype = ngotype(n);
} }
a->pun = n->pun;
a->offset = n->xoffset; a->offset = n->xoffset;
a->sym = n->sym; a->sym = n->sym;
if(a->sym == S) if(a->sym == S)

View File

@ -879,6 +879,8 @@ mkvar(Reg *r, Adr *a)
} }
} }
} }
if(a->pun)
flag = 1;
switch(et) { switch(et) {
case 0: case 0:

View File

@ -30,6 +30,7 @@ struct Addr
uchar index; uchar index;
uchar etype; uchar etype;
uchar scale; /* doubles as width in DATA op */ uchar scale; /* doubles as width in DATA op */
uchar pun; /* dont register variable */
}; };
#define A ((Addr*)0) #define A ((Addr*)0)

View File

@ -710,6 +710,23 @@ gclean(void)
yyerror("reg %R left allocated at %lux", i, regpc[i]); 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. * allocate register of type t, leave in n.
* if o != N, o is desired fixed register. * 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->width = n->type->width;
a->gotype = ngotype(n); a->gotype = ngotype(n);
} }
a->pun = n->pun;
a->offset = n->xoffset; a->offset = n->xoffset;
a->sym = n->sym; a->sym = n->sym;
if(a->sym == S) if(a->sym == S)

View File

@ -794,6 +794,8 @@ mkvar(Reg *r, Adr *a)
} }
} }
} }
if(a->pun)
flag = 1;
switch(et) { switch(et) {
case 0: case 0:

View File

@ -663,4 +663,5 @@ tempname(Node *n, Type *t)
stksize += w; stksize += w;
stksize = rnd(stksize, w); stksize = rnd(stksize, w);
n->xoffset = -stksize; n->xoffset = -stksize;
n->pun = anyregalloc();
} }

View File

@ -215,6 +215,7 @@ struct Node
uchar used; uchar used;
uchar oldref; uchar oldref;
uchar isddd; uchar isddd;
uchar pun; // dont registerize variable ONAME
// most nodes // most nodes
Node* left; Node* left;
@ -1241,3 +1242,4 @@ int duintptr(Sym *s, int off, uint64 v);
int duintxx(Sym *s, int off, uint64 v, int wid); int duintxx(Sym *s, int off, uint64 v, int wid);
void genembedtramp(Type*, Type*, Sym*); void genembedtramp(Type*, Type*, Sym*);
int gen_as_init(Node*); int gen_as_init(Node*);
int anyregalloc();