From: Keith Randall Date: Thu, 13 Jun 2024 03:24:44 +0000 (-0700) Subject: cmd/compile: don't treat an InlMark as a read during deadstore X-Git-Tag: go1.24rc1~1424 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=b0f7be3cfa1ee5fbfe46590475861677cc9514fa;p=gostls13.git 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 LUCI-TryBot-Result: Go LUCI Reviewed-by: Keith Randall --- diff --git a/src/cmd/compile/internal/ssa/deadstore.go b/src/cmd/compile/internal/ssa/deadstore.go index ce04cb3a24..a0d61bad03 100644 --- a/src/cmd/compile/internal/ssa/deadstore.go +++ b/src/cmd/compile/internal/ssa/deadstore.go @@ -59,6 +59,10 @@ func dse(f *Func) { continue } } + if v.Op == OpInlMark { + // Not really a use of the memory. See #67957. + continue + } for _, a := range v.Args { if a.Block == b && a.Type.IsMemory() { loadUse.add(a.ID) diff --git a/src/runtime/symtabinl_test.go b/src/runtime/symtabinl_test.go index db682e0c9c..ab58c05380 100644 --- a/src/runtime/symtabinl_test.go +++ b/src/runtime/symtabinl_test.go @@ -107,16 +107,17 @@ func lineNumber() int { // Below here is the test data for XTestInlineUnwinder var tiuStart = lineNumber() // +0 -var tiu1, tiu2, tiu3 int // +1 -func tiuInlined1() { // +2 - tiu1++ // +3 +var tiu2, tiu3 int // +1 +func tiuInlined1(i int) { // +2 + tiu1[i]++ // +3 } // +4 func tiuInlined2() { // +5 - tiuInlined1() // +6 - tiu2++ // +7 + tiuInlined1(1) // +6 + tiu2++ // +7 } // +8 func tiuTest() { // +9 - tiuInlined1() // +10 - tiuInlined2() // +11 - tiu3++ // +12 -} // +13 + tiuInlined1(0) // +10 + tiuInlined2() // +11 + tiu3++ // +12 +} // +13 +var tiu1 [2]int // +14