aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2015-02-03 12:48:35 +0300
committerDmitry Vyukov <dvyukov@google.com>2015-02-12 08:31:05 +0000
commitc1bbf0a2eac5a6ad71debb050cd46384649fcb04 (patch)
tree93d08d97bca7c474593bb9721cf6c3486eecb772 /src
parent9568126f350b10163155045445cb149323a2b5c8 (diff)
downloadgo-c1bbf0a2eac5a6ad71debb050cd46384649fcb04.tar.xz
cmd/gc: remove several copies of outervalue
Walk calls it outervalue, racewalk calls it basenod, isstack does it manually and slightly differently. Change-Id: Id5b5d32b8faf143fe9d34bd08457bfab6fb33daa Reviewed-on: https://go-review.googlesource.com/3745 Reviewed-by: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src')
-rw-r--r--src/cmd/gc/racewalk.c34
-rw-r--r--src/cmd/gc/walk.c10
2 files changed, 12 insertions, 32 deletions
diff --git a/src/cmd/gc/racewalk.c b/src/cmd/gc/racewalk.c
index f3134dab23..757b02cb12 100644
--- a/src/cmd/gc/racewalk.c
+++ b/src/cmd/gc/racewalk.c
@@ -24,7 +24,6 @@ static void racewalknode(Node **np, NodeList **init, int wr, int skip);
static int callinstr(Node **n, NodeList **init, int wr, int skip);
static Node* uintptraddr(Node *n);
static void makeaddable(Node *n);
-static Node* basenod(Node *n);
static void foreach(Node *n, void(*f)(Node*, void*), void *c);
static void hascallspred(Node *n, void *c);
static void appendinit(Node **np, NodeList *init);
@@ -155,12 +154,8 @@ racewalknode(Node **np, NodeList **init, int wr, int skip)
default:
fatal("racewalk: unknown node type %O", n->op);
- case OASOP:
case OAS:
- case OAS2:
- case OAS2RECV:
case OAS2FUNC:
- case OAS2MAPR:
racewalknode(&n->left, init, 1, 0);
racewalknode(&n->right, init, 0, 0);
goto ret;
@@ -350,7 +345,7 @@ racewalknode(Node **np, NodeList **init, int wr, int skip)
goto ret;
case OEFACE:
- racewalknode(&n->left, init, 0, 0);
+ // n->left is Type* which is not interesting.
racewalknode(&n->right, init, 0, 0);
goto ret;
@@ -393,6 +388,10 @@ racewalknode(Node **np, NodeList **init, int wr, int skip)
case OARRAYLIT: // lowered to assignments
case OMAPLIT:
case OSTRUCTLIT:
+ case OAS2:
+ case OAS2RECV:
+ case OAS2MAPR:
+ case OASOP:
yyerror("racewalk: %O must be lowered by now", n->op);
goto ret;
@@ -489,7 +488,7 @@ callinstr(Node **np, NodeList **init, int wr, int skip)
if(isartificial(n))
return 0;
- b = basenod(n);
+ b = outervalue(n);
// it skips e.g. stores to ... parameter array
if(isartificial(b))
return 0;
@@ -499,7 +498,7 @@ callinstr(Node **np, NodeList **init, int wr, int skip)
// that has got a pointer inside. Whether it points to
// the heap or not is impossible to know at compile time
if((class&PHEAP) || class == PPARAMREF || class == PEXTERN
- || b->op == OINDEX || b->op == ODOTPTR || b->op == OIND || b->op == OXDOT) {
+ || b->op == OINDEX || b->op == ODOTPTR || b->op == OIND) {
hascalls = 0;
foreach(n, hascallspred, &hascalls);
if(hascalls) {
@@ -568,25 +567,6 @@ uintptraddr(Node *n)
return r;
}
-// basenod returns the simplest child node of n pointing to the same
-// memory area.
-static Node*
-basenod(Node *n)
-{
- for(;;) {
- if(n->op == ODOT || n->op == OXDOT || n->op == OCONVNOP || n->op == OCONV || n->op == OPAREN) {
- n = n->left;
- continue;
- }
- if(n->op == OINDEX && isfixedarray(n->type)) {
- n = n->left;
- continue;
- }
- break;
- }
- return n;
-}
-
static Node*
detachexpr(Node *n, NodeList **init)
{
diff --git a/src/cmd/gc/walk.c b/src/cmd/gc/walk.c
index 91568371d7..99dd0d3c09 100644
--- a/src/cmd/gc/walk.c
+++ b/src/cmd/gc/walk.c
@@ -1963,8 +1963,7 @@ isstack(Node *n)
{
Node *defn;
- while(n->op == ODOT || n->op == OPAREN || n->op == OCONVNOP || n->op == OINDEX && isfixedarray(n->left->type))
- n = n->left;
+ n = outervalue(n);
// If n is *autotmp and autotmp = &foo, replace n with foo.
// We introduce such temps when initializing struct literals.
@@ -1995,8 +1994,7 @@ isstack(Node *n)
static int
isglobal(Node *n)
{
- while(n->op == ODOT || n->op == OPAREN || n->op == OCONVNOP || n->op == OINDEX && isfixedarray(n->left->type))
- n = n->left;
+ n = outervalue(n);
switch(n->op) {
case ONAME:
@@ -2355,7 +2353,9 @@ Node*
outervalue(Node *n)
{
for(;;) {
- if(n->op == ODOT || n->op == OPAREN) {
+ if(n->op == OXDOT)
+ fatal("OXDOT in walk");
+ if(n->op == ODOT || n->op == OPAREN || n->op == OCONVNOP) {
n = n->left;
continue;
}