mirror of
https://github.com/golang/go
synced 2024-11-26 09:28:07 -07:00
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>
This commit is contained in:
parent
d3853fb4e6
commit
e8666abd98
@ -201,8 +201,9 @@ func elimDeadAutosGeneric(f *Func) {
|
|||||||
panic("unhandled op with sym effect")
|
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.
|
// Nil check has no use, but we need to keep it.
|
||||||
|
// Also keep calls and values that have side effects.
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
16
test/fixedbugs/issue45693.go
Normal file
16
test/fixedbugs/issue45693.go
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// compile
|
||||||
|
|
||||||
|
// Copyright 2021 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// Issue 45693: ICE with register args.
|
||||||
|
|
||||||
|
package p
|
||||||
|
|
||||||
|
func f() {
|
||||||
|
var s string
|
||||||
|
s = s + "" + s + "" + s + ""
|
||||||
|
for {
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user