Commit 00d2f916 authored by Russ Cox's avatar Russ Cox

cmd/gc: run escape analysis always (even in -N mode)

Fixes #8585.
Removes some little-used code paths.

LGTM=josharian
R=golang-codereviews, minux, josharian
CC=golang-codereviews, iant, r
https://golang.org/cl/132970043
parent 50c9d634
......@@ -54,9 +54,6 @@ addrescapes(Node *n)
if(n->class == PAUTO && n->esc == EscNever)
break;
if(debug['N'] && n->esc != EscUnknown)
fatal("without escape analysis, only PAUTO's should have esc: %N", n);
switch(n->class) {
case PPARAMREF:
addrescapes(n->defn);
......@@ -91,8 +88,7 @@ addrescapes(Node *n)
snprint(buf, sizeof buf, "&%S", n->sym);
n->heapaddr->sym = lookup(buf);
n->heapaddr->orig->sym = n->heapaddr->sym;
if(!debug['N'])
n->esc = EscHeap;
n->esc = EscHeap;
if(debug['m'])
print("%L: moved to heap: %N\n", n->lineno, n);
curfn = oldfn;
......
......@@ -481,8 +481,12 @@ main(int argc, char *argv[])
}
// Phase 5: Escape analysis.
if(!debug['N'])
escapes(xtop);
// Required for moving heap allocations onto stack,
// which in turn is required by the closure implementation,
// which stores the addresses of stack variables into the closure.
// If the closure does not escape, it needs to be on the stack
// or else the stack copier will not update it.
escapes(xtop);
// Escape analysis moved escaped values off stack.
// Move large values off stack too.
......
......@@ -736,10 +736,6 @@ reswitch:
l = n->left;
if((t = l->type) == T)
goto error;
// top&Eindir means this is &x in *&x. (or the arg to built-in print)
// n->etype means code generator flagged it as non-escaping.
if(debug['N'] && !(top & Eindir) && !n->etype)
addrescapes(n->left);
n->type = ptrto(t);
goto ret;
......@@ -2119,8 +2115,6 @@ lookdot(Node *n, Type *t, int dostrcmp)
if(!eqtype(rcvr, tt)) {
if(rcvr->etype == tptr && eqtype(rcvr->type, tt)) {
checklvalue(n->left, "call pointer method on");
if(debug['N'])
addrescapes(n->left);
n->left = nod(OADDR, n->left, N);
n->left->implicit = 1;
typecheck(&n->left, Etype|Erv);
......
......@@ -7,6 +7,8 @@
// Test, using compiler diagnostic flags, that the escape analysis is working.
// Compiles but does not run. Inlining is disabled.
// escape2n.go contains all the same tests but compiles with -N.
package foo
import (
......
This diff is collapsed.
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