]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: cull dead code
authorJosh Bleecher Snyder <josharian@gmail.com>
Sat, 10 Nov 2018 14:58:36 +0000 (06:58 -0800)
committerDaniel Martí <mvdan@mvdan.cc>
Tue, 26 Feb 2019 18:37:19 +0000 (18:37 +0000)
The special case for ODOTPTR to handle zero-width fields is unneeded.
It is an artifact of the old backend, from which time this code dates.
The Node to SSA converter is careful to insert a nil check.
This is tested in test/nilptr2.go, among other places.

Passes toolstash-check.

Change-Id: I6c1d99f7ff5abdae9aa08ee047dc088a3fe8dc3c
Reviewed-on: https://go-review.googlesource.com/c/148828
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/cmd/compile/internal/gc/walk.go

index 509579d21fe9cd170e8746981f796719a4dcd6c7..9bfdaffa627bd047f6cee856dfb1d9014d7f1dba 100644 (file)
@@ -493,7 +493,7 @@ opswitch:
                n.Left = walkexpr(n.Left, init)
                n.Right = walkexpr(n.Right, init)
 
-       case ODOT:
+       case ODOT, ODOTPTR:
                usefield(n)
                n.Left = walkexpr(n.Left, init)
 
@@ -508,17 +508,6 @@ opswitch:
                        n.List.Set1(itabname(n.Type, n.Left.Type))
                }
 
-       case ODOTPTR:
-               usefield(n)
-               if n.Op == ODOTPTR && n.Left.Type.Elem().Width == 0 {
-                       // No actual copy will be generated, so emit an explicit nil check.
-                       n.Left = cheapexpr(n.Left, init)
-
-                       checknil(n.Left, init)
-               }
-
-               n.Left = walkexpr(n.Left, init)
-
        case OLEN, OCAP:
                if isRuneCount(n) {
                        // Replace len([]rune(string)) with runtime.countrunes(string).