]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: revise inliner coverage tweaks (again)
authorThan McIntosh <thanm@google.com>
Fri, 28 Oct 2022 17:21:36 +0000 (13:21 -0400)
committerThan McIntosh <thanm@google.com>
Tue, 1 Nov 2022 14:12:12 +0000 (14:12 +0000)
This patch fixes a typo/bug introduced in CL 441858 where when pattern
matching a coverage counter access we were looking at an assingment
node instead of the assignment LHS, and fixes a similar problem in
atomic counter update pattern matching introduced in CL 444835. In
both of these cases the bug was not caught because the test intended
to lock down the behavior was written incorrectly (wasn't
instrumenting what the test author thought it was instrumenting,
ouch).

Change-Id: I6e6ac3beacf12ef1a817de5527340b639f0bb044
Reviewed-on: https://go-review.googlesource.com/c/go/+/446258
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Than McIntosh <thanm@google.com>

src/cmd/compile/internal/inline/inl.go

index 4909650ae4b1b5f81c65f7b76f6b41307e6c8120..75f3a4b9070a12a1c7d9da8cb5aaa11e608f7bef 100644 (file)
@@ -412,7 +412,7 @@ func (v *hairyVisitor) doNode(n ir.Node) bool {
                        // failures (a good example is the TestAllocations in
                        // crypto/ed25519).
                        if isAtomicCoverageCounterUpdate(n) {
-                               break
+                               return false
                        }
                }
                if n.X.Op() == ir.OMETHEXPR {
@@ -629,7 +629,7 @@ func (v *hairyVisitor) doNode(n ir.Node) bool {
                // then result in test failures (a good example is the
                // TestAllocations in crypto/ed25519).
                n := n.(*ir.AssignStmt)
-               if n.X.Op() == ir.OINDEX && isIndexingCoverageCounter(n) {
+               if n.X.Op() == ir.OINDEX && isIndexingCoverageCounter(n.X) {
                        return false
                }
        }
@@ -1729,7 +1729,8 @@ func isAtomicCoverageCounterUpdate(cn *ir.CallExpr) bool {
                return false
        }
        fn := name.Sym().Name
-       if name.Sym().Pkg.Path != "sync/atomic" || fn != "AddUint32" {
+       if name.Sym().Pkg.Path != "sync/atomic" ||
+               (fn != "AddUint32" && fn != "StoreUint32") {
                return false
        }
        if len(cn.Args) != 2 || cn.Args[0].Op() != ir.OADDR {