]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: don't treat an InlMark as a read during deadstore
authorKeith Randall <khr@golang.org>
Thu, 13 Jun 2024 03:24:44 +0000 (20:24 -0700)
committerKeith Randall <khr@google.com>
Tue, 23 Jul 2024 20:55:24 +0000 (20:55 +0000)
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>
src/cmd/compile/internal/ssa/deadstore.go
src/runtime/symtabinl_test.go

index ce04cb3a24ff72c8f22e67f8e64e206ec5392bda..a0d61bad03b2b967bae973bcfe7f014e22925f0a 100644 (file)
@@ -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)
index db682e0c9caa8c03a49ed297d1fb44b4bfa48079..ab58c053805e24dc5a29852a5fc6244cfc1960c6 100644 (file)
@@ -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