summaryrefslogtreecommitdiff
path: root/src/cmd/5g
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2014-02-13 22:45:16 -0500
committerRuss Cox <rsc@golang.org>2014-02-13 22:45:16 -0500
commit4203ada85b00e5de41bf8efe1f99901633c866dd (patch)
tree10f0fbd20d3f66793a46411426cbe871f11e680a /src/cmd/5g
parente37f4869e55dee6d55a034e644c32bbd268fe9c9 (diff)
downloadgo-4203ada85b00e5de41bf8efe1f99901633c866dd.tar.gz
cmd/gc: handle variable initialization by block move in liveness
Any initialization of a variable by a block copy or block zeroing or by multiple assignments (componentwise copying or zeroing of a multiword variable) needs to emit a VARDEF. These cases were not. Fixes issue 7205. TBR=iant CC=golang-codereviews https://codereview.appspot.com/63650044
Diffstat (limited to 'src/cmd/5g')
-rw-r--r--src/cmd/5g/cgen.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/cmd/5g/cgen.c b/src/cmd/5g/cgen.c
index 2d260e72d..a5ac6c15b 100644
--- a/src/cmd/5g/cgen.c
+++ b/src/cmd/5g/cgen.c
@@ -1414,6 +1414,7 @@ sgen(Node *n, Node *res, int64 w)
int32 c, odst, osrc;
int dir, align, op;
Prog *p, *ploop;
+ NodeList *l;
if(debug['g']) {
print("\nsgen w=%lld\n", w);
@@ -1439,6 +1440,17 @@ sgen(Node *n, Node *res, int64 w)
return;
}
+ // Record site of definition of ns for liveness analysis.
+ if(res->op == ONAME && res->class != PEXTERN)
+ gvardef(res);
+
+ // If copying .args, that's all the results, so record definition sites
+ // for them for the liveness analysis.
+ if(res->op == ONAME && strcmp(res->sym->name, ".args") == 0)
+ for(l = curfn->dcl; l != nil; l = l->next)
+ if(l->n->class == PPARAMOUT)
+ gvardef(l->n);
+
// Avoid taking the address for simple enough types.
if(componentgen(n, res))
return;