]> Cypherpunks repositories - gostls13.git/commitdiff
undo CL 102820043 / b0ce6dbafc18
authorRuss Cox <rsc@golang.org>
Thu, 29 May 2014 01:46:20 +0000 (21:46 -0400)
committerRuss Cox <rsc@golang.org>
Thu, 29 May 2014 01:46:20 +0000 (21:46 -0400)
Breaks 386 and arm builds.
The obvious reason is that this CL only edited 6g/gsubr.c
and failed to edit 5g/gsubr.c and 8g/gsubr.c.
However, the obvious CL applying the same edit to those
files (CL 101900043) causes mysterious build failures
in various of the standard package tests, usually involving
reflect. Something deep and subtle is broken but only on
the 32-bit systems.

Undo this CL for now.

««« original CL description
cmd/gc: fix x=x crash

The 'nodarg' function is used to obtain a Node*
representing a function argument or result.
It returned a brand new Node*, but that violates
the guarantee in most places in the compiler that
two Node*s refer to the same variable if and only if
they are the same Node* pointer. Reestablish that
invariant by making nodarg return a preexisting
named variable if present.

Having fixed that, avoid any copy during x=x in
componentgen, because the VARDEF we emit
before the copy marks the lhs x as dead incorrectly.

The change in walk.c avoids modifying the result
of nodarg. This was the only place in the compiler
that did so.

Fixes #8097.

LGTM=r, khr
R=golang-codereviews, r, khr
CC=golang-codereviews, iant
https://golang.org/cl/102820043
»»»

TBR=r
CC=golang-codereviews, khr
https://golang.org/cl/95660043

src/cmd/5g/cgen.c
src/cmd/6g/cgen.c
src/cmd/6g/gsubr.c
src/cmd/8g/cgen.c
src/cmd/gc/walk.c
test/live.go

index 9011b20228932d4fb0e27715933272b2710d0f32..9faf75461751acd6dd0244b9559acfcb8d3db038 100644 (file)
@@ -1490,7 +1490,6 @@ sgen(Node *n, Node *res, int64 w)
        }
        if(osrc%align != 0 || odst%align != 0)
                fatal("sgen: unaligned offset src %d or dst %d (align %d)", osrc, odst, align);
-
        // if we are copying forward on the stack and
        // the src and dst overlap, then reverse direction
        dir = align;
@@ -1675,13 +1674,6 @@ componentgen(Node *nr, Node *nl)
                freer = 1;
        }
 
-       // nl and nr are 'cadable' which basically means they are names (variables) now.
-       // If they are the same variable, don't generate any code, because the
-       // VARDEF we generate will mark the old value as dead incorrectly.
-       // (And also the assignments are useless.)
-       if(nr != N && nl->op == ONAME && nr->op == ONAME && nl == nr)
-               goto yes;
-
        switch(nl->type->etype) {
        case TARRAY:
                if(nl->op == ONAME)
index 4dd505b086d76813d8a92b7951b035d7ce988af3..ae1309142c9f778844f1e1f0f87fb3c8c450a3d4 100644 (file)
@@ -1585,13 +1585,6 @@ componentgen(Node *nr, Node *nl)
                        freer = 1;
                }
        }
-       
-       // nl and nr are 'cadable' which basically means they are names (variables) now.
-       // If they are the same variable, don't generate any code, because the
-       // VARDEF we generate will mark the old value as dead incorrectly.
-       // (And also the assignments are useless.)
-       if(nr != N && nl->op == ONAME && nr->op == ONAME && nl == nr)
-               goto yes;
 
        switch(nl->type->etype) {
        case TARRAY:
index e4d00bf4192ee64daf541cec2e8035447f30d424..bd2f2304b455fa21c720dc7555b9a1e9ef3371f7 100644 (file)
@@ -462,7 +462,6 @@ Node*
 nodarg(Type *t, int fp)
 {
        Node *n;
-       NodeList *l;
        Type *first;
        Iter savet;
 
@@ -483,14 +482,6 @@ nodarg(Type *t, int fp)
 
        if(t->etype != TFIELD)
                fatal("nodarg: not field %T", t);
-       
-       if(fp == 1) {
-               for(l=curfn->dcl; l; l=l->next) {
-                       n = l->n;
-                       if((n->class == PPARAM || n->class == PPARAMOUT) && !isblanksym(t->sym) && n->sym == t->sym)
-                               return n;
-               }
-       }
 
        n = nod(ONAME, N, N);
        n->type = t->type;
index d626c2eb02ef894c9d635c434ca9146c7b90fdc0..1aae7771c7110122fc07ca3698556fbf179272a7 100644 (file)
@@ -1397,13 +1397,6 @@ componentgen(Node *nr, Node *nl)
                }
        }
 
-       // nl and nr are 'cadable' which basically means they are names (variables) now.
-       // If they are the same variable, don't generate any code, because the
-       // VARDEF we generate will mark the old value as dead incorrectly.
-       // (And also the assignments are useless.)
-       if(nr != N && nl->op == ONAME && nr->op == ONAME && nl == nr)
-               goto yes;
-
        switch(nl->type->etype) {
        case TARRAY:
                if(nl->op == ONAME)
index 1cb25512e5e2868d34711d9e5026aae5806a5b6b..2d402d04f55f4f389049fed50433d07ad65589a8 100644 (file)
@@ -1652,8 +1652,7 @@ ascompatte(int op, Node *call, int isddd, Type **nl, NodeList *lr, int fp, NodeL
                // optimization - can do block copy
                if(eqtypenoname(r->type, *nl)) {
                        a = nodarg(*nl, fp);
-                       r = nod(OCONVNOP, r, N);
-                       r->type = a->type;
+                       a->type = r->type;
                        nn = list1(convas(nod(OAS, a, r), init));
                        goto ret;
                }
index 286fcc30640ef87f63e799e70442d8e2cfff3c56..21d3e6a5fa79a1af7a16bdbc9b6c8d39c34ea171 100644 (file)
@@ -564,29 +564,3 @@ func f38(b bool) {
        }
        println()
 }
-
-// issue 8097: mishandling of x = x during return.
-
-func f39() (x []int) {
-       x = []int{1}
-       println() // ERROR "live at call to printnl: x"
-       return x
-}
-
-func f39a() (x []int) {
-       x = []int{1}
-       println() // ERROR "live at call to printnl: x"
-       return
-}
-
-func f39b() (x [10]*int) {
-       x = [10]*int{new(int)} // ERROR "live at call to new: x"
-       println() // ERROR "live at call to printnl: x"
-       return x
-}
-
-func f39c() (x [10]*int) {
-       x = [10]*int{new(int)} // ERROR "live at call to new: x"
-       println() // ERROR "live at call to printnl: x"
-       return
-}