Skip to content
This repository has been archived by the owner on May 2, 2018. It is now read-only.

Commit

Permalink
cmd/compile: fix varexpr handling of ODOT
Browse files Browse the repository at this point in the history
For a long time varexpr has handled ODOT incorrectly: it has always
returned false.  Before https://golang.org/cl/20890 this has been
because an ODOT had a Right field with an ONAME with no Class, for which
varexpr returns false.  CL 20890 preserved the behavior of varexpr for
ODOT, so that the change would pass toolstash -cmp.

This CL fixes varexpr so that ODOT can return true in some cases.  This
breaks toolstash -cmp.  While the changed compiler allocates temporary
variables in a different order, I have not been able to find any
examples where the generated code is different, other than using
different stack offsets and, in some cases, registers.  It seems that
other parts of the compiler will force the ODOT into a temporary anyhow.

Still, this change is clearly correct, and is a minor compiler cleanup.

Change-Id: I71506877aa3c13966bb03c281aa16271ee7fe80a
Reviewed-on: https://go-review.googlesource.com/20907
Run-TryBot: Ian Lance Taylor <[email protected]>
Reviewed-by: David Crawshaw <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
  • Loading branch information
ianlancetaylor committed Mar 20, 2016
1 parent 93098de commit a9407b5
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/cmd/compile/internal/gc/walk.go
Original file line number Diff line number Diff line change
Expand Up @@ -2487,10 +2487,7 @@ func varexpr(n *Node) bool {
return varexpr(n.Left) && varexpr(n.Right)

case ODOT: // but not ODOTPTR
// The original code always returned false for ODOT,
// because n.Right would be an ONAME with n.Class not set.
// TODO(iant): Fix this to remove "&& false".
return varexpr(n.Left) && false
return varexpr(n.Left)
}

// Be conservative.
Expand Down

0 comments on commit a9407b5

Please sign in to comment.