Commit 8027660a authored by Russ Cox's avatar Russ Cox

cmd/gc: fix crash in -live debugging output

R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/53930043
parent cdc55655
...@@ -635,7 +635,9 @@ isfunny(Node *node) ...@@ -635,7 +635,9 @@ isfunny(Node *node)
// //
// The output vectors give bits for variables: // The output vectors give bits for variables:
// uevar - used by this instruction // uevar - used by this instruction
// varkill - set by this instruction // varkill - killed by this instruction
// for variables without address taken, means variable was set
// for variables with address taken, means variable was marked dead
// avarinit - initialized or referred to by this instruction, // avarinit - initialized or referred to by this instruction,
// only for variables with address taken but not escaping to heap // only for variables with address taken but not escaping to heap
// //
...@@ -694,8 +696,9 @@ progeffects(Prog *prog, Array *vars, Bvec *uevar, Bvec *varkill, Bvec *avarinit) ...@@ -694,8 +696,9 @@ progeffects(Prog *prog, Array *vars, Bvec *uevar, Bvec *varkill, Bvec *avarinit)
pos = arrayindexof(vars, from->node); pos = arrayindexof(vars, from->node);
if(pos == -1) if(pos == -1)
goto Next; goto Next;
if(from->node->addrtaken) if(from->node->addrtaken) {
bvset(avarinit, pos); bvset(avarinit, pos);
} else {
if(info.flags & (LeftRead | LeftAddr)) if(info.flags & (LeftRead | LeftAddr))
bvset(uevar, pos); bvset(uevar, pos);
if(info.flags & LeftWrite) if(info.flags & LeftWrite)
...@@ -704,6 +707,7 @@ progeffects(Prog *prog, Array *vars, Bvec *uevar, Bvec *varkill, Bvec *avarinit) ...@@ -704,6 +707,7 @@ progeffects(Prog *prog, Array *vars, Bvec *uevar, Bvec *varkill, Bvec *avarinit)
} }
} }
} }
}
Next: Next:
if(info.flags & (RightRead | RightWrite | RightAddr)) { if(info.flags & (RightRead | RightWrite | RightAddr)) {
to = &prog->to; to = &prog->to;
...@@ -715,8 +719,12 @@ Next: ...@@ -715,8 +719,12 @@ Next:
pos = arrayindexof(vars, to->node); pos = arrayindexof(vars, to->node);
if(pos == -1) if(pos == -1)
goto Next1; goto Next1;
if(to->node->addrtaken) if(to->node->addrtaken) {
if(prog->as == AKILL)
bvset(varkill, pos);
else
bvset(avarinit, pos); bvset(avarinit, pos);
} else {
if(info.flags & (RightRead | RightAddr)) if(info.flags & (RightRead | RightAddr))
bvset(uevar, pos); bvset(uevar, pos);
if(info.flags & RightWrite) if(info.flags & RightWrite)
...@@ -725,6 +733,7 @@ Next: ...@@ -725,6 +733,7 @@ Next:
} }
} }
} }
}
Next1:; Next1:;
} }
...@@ -1589,8 +1598,10 @@ livenessepilogue(Liveness *lv) ...@@ -1589,8 +1598,10 @@ livenessepilogue(Liveness *lv)
if(debuglive >= 1) { if(debuglive >= 1) {
fmtstrinit(&fmt); fmtstrinit(&fmt);
fmtprint(&fmt, "%L: live at ", p->lineno); fmtprint(&fmt, "%L: live at ", p->lineno);
if(p->as == ACALL) if(p->as == ACALL && p->to.node)
fmtprint(&fmt, "call to %s:", p->to.node->sym->name); fmtprint(&fmt, "call to %s:", p->to.node->sym->name);
else if(p->as == ACALL)
fmtprint(&fmt, "indirect call:");
else else
fmtprint(&fmt, "entry to %s:", p->from.node->sym->name); fmtprint(&fmt, "entry to %s:", p->from.node->sym->name);
numlive = 0; numlive = 0;
......
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