]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: minor cleanup to HashDebugPos
authorDavid Chase <drchase@google.com>
Thu, 6 Apr 2023 14:09:51 +0000 (10:09 -0400)
committerDavid Chase <drchase@google.com>
Fri, 7 Apr 2023 21:05:01 +0000 (21:05 +0000)
HashDebugPos function/method included a parameter that was always
the same, and a variable in the same package as the hashdebug code.
So remove it.

(I wrote that code, there was no reason for it to be that way).

Also corrects a stale comment in the loopvar code.

Change-Id: Id3da69cfe6dadeb31d5de62fb76d15103a5d6152
Reviewed-on: https://go-review.googlesource.com/c/go/+/482816
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
src/cmd/compile/internal/base/flag.go
src/cmd/compile/internal/base/hashdebug.go
src/cmd/compile/internal/loopvar/loopvar.go
src/cmd/compile/internal/ssa/func.go

index d9ce42255bcb5a6cffc9a6c7dac4fa806103bc38..9b6caf56266732c0a12760018adf0f13ca6e8661 100644 (file)
@@ -208,8 +208,8 @@ func ParseFlags() {
        //  GOCOMPILEDEBUG=loopvarhash=... -- search for failure cause
        //
        //  (*) For debugging purposes, providing loopvar flag >= 11 will expand the hash-eligible set of loops to all.
-       // (**) Currently this applies to all code in the compilation of some_package, including
-       //     inlines from other packages that may have been compiled w/o the change.
+       // (**) Loop semantics, changed or not, follow code from a package when it is inlined; that is, the behavior
+       //      of an application compiled with partially modified loop semantics does not depend on inlining.
 
        if Debug.LoopVarHash != "" {
                // This first little bit controls the inputs for debug-hash-matching.
index 1322768b414bb7fc94337c00e6ddb2340b19d53d..6276abe4fd27fd9651e4fb87b780ad6fbda9ecbd 100644 (file)
@@ -138,6 +138,10 @@ func DebugHashMatch(pkgAndName string) bool {
        return hashDebug.DebugHashMatch(pkgAndName)
 }
 
+func DebugHashMatchPos(pos src.XPos) bool {
+       return hashDebug.DebugHashMatchPos(pos)
+}
+
 // HasDebugHash returns true if Flags.Gossahash is non-empty, which
 // results in hashDebug being not-nil.  I.e., if !HasDebugHash(),
 // there is no need to create the string for hashing and testing.
@@ -317,7 +321,7 @@ func (d *HashDebug) DebugHashMatchParam(pkgAndName string, param uint64) bool {
 // locking is also more frequent and more granular.
 // Note that the default answer for no environment variable (d == nil)
 // is "yes", do the thing.
-func (d *HashDebug) DebugHashMatchPos(ctxt *obj.Link, pos src.XPos) bool {
+func (d *HashDebug) DebugHashMatchPos(pos src.XPos) bool {
        if d == nil {
                return true
        }
@@ -325,7 +329,7 @@ func (d *HashDebug) DebugHashMatchPos(ctxt *obj.Link, pos src.XPos) bool {
                return false
        }
        // Written this way to make inlining likely.
-       return d.debugHashMatchPos(ctxt, pos)
+       return d.debugHashMatchPos(Ctxt, pos)
 }
 
 func (d *HashDebug) debugHashMatchPos(ctxt *obj.Link, pos src.XPos) bool {
index c92b9d61ea360b72b1c6eded321b2a4eb950a4c6..ce0c41c58569f4ab668a79c268c1b3295cb5e18c 100644 (file)
@@ -71,7 +71,7 @@ func ForCapture(fn *ir.Func) []*ir.Name {
                // subject to hash-variable debugging.
                maybeReplaceVar := func(k ir.Node, x *ir.RangeStmt) ir.Node {
                        if n, ok := k.(*ir.Name); ok && possiblyLeaked[n] {
-                               if base.LoopVarHash.DebugHashMatchPos(base.Ctxt, n.Pos()) {
+                               if base.LoopVarHash.DebugHashMatchPos(n.Pos()) {
                                        // Rename the loop key, prefix body with assignment from loop key
                                        transformed = append(transformed, n)
                                        tk := typecheck.Temp(n.Type())
@@ -167,7 +167,7 @@ func ForCapture(fn *ir.Func) []*ir.Name {
                                forAllDefInInit(x, func(z ir.Node) {
                                        if n, ok := z.(*ir.Name); ok && possiblyLeaked[n] {
                                                // Hash on n.Pos() for most precise failure location.
-                                               if base.LoopVarHash.DebugHashMatchPos(base.Ctxt, n.Pos()) {
+                                               if base.LoopVarHash.DebugHashMatchPos(n.Pos()) {
                                                        leaked = append(leaked, n)
                                                }
                                        }
index ba3d1e589e7e30d721cb8f4b1be2aedde7ee7678..f106cdd0b9f1c702aa67a95678c7cf3c2403b12e 100644 (file)
@@ -808,6 +808,5 @@ func (f *Func) useFMA(v *Value) bool {
        if base.FmaHash == nil {
                return true
        }
-       ctxt := v.Block.Func.Config.Ctxt()
-       return base.FmaHash.DebugHashMatchPos(ctxt, v.Pos)
+       return base.FmaHash.DebugHashMatchPos(v.Pos)
 }