diff options
author | Cherry Zhang <cherryyz@google.com> | 2021-04-22 11:36:29 -0400 |
---|---|---|
committer | Cherry Zhang <cherryyz@google.com> | 2021-04-22 16:38:37 +0000 |
commit | e8666abd9884f6743f78229ed210bf12a35e7368 (patch) | |
tree | 1c6cfff8f5e611ebf530c280e7be51ebe8085091 /src/cmd/compile/internal/ssa | |
parent | d3853fb4e6ee2b9f873ab2e41adc0e62a82e73e4 (diff) | |
download | go-e8666abd9884f6743f78229ed210bf12a35e7368.tar.gz go-e8666abd9884f6743f78229ed210bf12a35e7368.zip |
cmd/compile: keep call's args in elim dead auto pass
If the address of an auto is used in a Call, we need to keep it,
as we keep the Call itself.
Fixes #45693.
Change-Id: Ie548d6dffc95bf916868a8885d4ab4cf9e86355a
Reviewed-on: https://go-review.googlesource.com/c/go/+/312670
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Diffstat (limited to 'src/cmd/compile/internal/ssa')
-rw-r--r-- | src/cmd/compile/internal/ssa/deadstore.go | 3 |
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 31d3f62d4e..d694133ec3 100644 --- a/src/cmd/compile/internal/ssa/deadstore.go +++ b/src/cmd/compile/internal/ssa/deadstore.go @@ -201,8 +201,9 @@ func elimDeadAutosGeneric(f *Func) { panic("unhandled op with sym effect") } - if v.Uses == 0 && v.Op != OpNilCheck || len(args) == 0 { + if v.Uses == 0 && v.Op != OpNilCheck && !v.Op.IsCall() && !v.Op.HasSideEffects() || len(args) == 0 { // Nil check has no use, but we need to keep it. + // Also keep calls and values that have side effects. return } |