aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/ssa/deadstore.go
diff options
context:
space:
mode:
authorCherry Zhang <cherryyz@google.com>2018-08-28 14:52:30 -0400
committerCherry Zhang <cherryyz@google.com>2018-08-30 02:19:37 +0000
commit54f9c0416a588963cb5a1c10ffb6a88f3956858c (patch)
tree32aa24296d9e250924ad08b6bdb134d816126114 /src/cmd/compile/internal/ssa/deadstore.go
parentf9a4ae018d99c5afb0e4f128545ff26e01d7b498 (diff)
downloadgo-54f9c0416a588963cb5a1c10ffb6a88f3956858c.tar.gz
go-54f9c0416a588963cb5a1c10ffb6a88f3956858c.zip
cmd/compile: count nil check as use in dead auto elim
Nil check is special in that it has no use but we must keep it. Count it as a use of the auto. Fixes #27278. Change-Id: I857c3d0db2ebdca1bc342b4993c0dac5c01e067f Reviewed-on: https://go-review.googlesource.com/131955 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/ssa/deadstore.go')
-rw-r--r--src/cmd/compile/internal/ssa/deadstore.go3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/cmd/compile/internal/ssa/deadstore.go b/src/cmd/compile/internal/ssa/deadstore.go
index 1caa61a966..69616b3a88 100644
--- a/src/cmd/compile/internal/ssa/deadstore.go
+++ b/src/cmd/compile/internal/ssa/deadstore.go
@@ -197,7 +197,8 @@ func elimDeadAutosGeneric(f *Func) {
panic("unhandled op with sym effect")
}
- if v.Uses == 0 || len(args) == 0 {
+ if v.Uses == 0 && v.Op != OpNilCheck || len(args) == 0 {
+ // Nil check has no use, but we need to keep it.
return
}