cmd/compile: don't treat an InlMark as a read during deadstore

An InlMark "read" can't make an otherwise dead store live. Without this
CL, we sometimes zero an object twice in succession because we think
there is a reader in between.

Kind of challenging to make a test for this. The second zeroing has the
same instruction on the same line number, so codegen tests can't see it.

Fixes #67957

Change-Id: I7fb97ebff50d8eb6246fc4802d1136b7cc76c45f
Reviewed-on: https://go-review.googlesource.com/c/go/+/592615
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
This commit is contained in:
Keith Randall 2024-06-12 20:24:44 -07:00 committed by Keith Randall
parent f66db49976
commit b0f7be3cfa
2 changed files with 14 additions and 9 deletions

View File

@ -59,6 +59,10 @@ func dse(f *Func) {
continue continue
} }
} }
if v.Op == OpInlMark {
// Not really a use of the memory. See #67957.
continue
}
for _, a := range v.Args { for _, a := range v.Args {
if a.Block == b && a.Type.IsMemory() { if a.Block == b && a.Type.IsMemory() {
loadUse.add(a.ID) loadUse.add(a.ID)

View File

@ -107,16 +107,17 @@ func lineNumber() int {
// Below here is the test data for XTestInlineUnwinder // Below here is the test data for XTestInlineUnwinder
var tiuStart = lineNumber() // +0 var tiuStart = lineNumber() // +0
var tiu1, tiu2, tiu3 int // +1 var tiu2, tiu3 int // +1
func tiuInlined1() { // +2 func tiuInlined1(i int) { // +2
tiu1++ // +3 tiu1[i]++ // +3
} // +4 } // +4
func tiuInlined2() { // +5 func tiuInlined2() { // +5
tiuInlined1() // +6 tiuInlined1(1) // +6
tiu2++ // +7 tiu2++ // +7
} // +8 } // +8
func tiuTest() { // +9 func tiuTest() { // +9
tiuInlined1() // +10 tiuInlined1(0) // +10
tiuInlined2() // +11 tiuInlined2() // +11
tiu3++ // +12 tiu3++ // +12
} // +13 } // +13
var tiu1 [2]int // +14