From: David Chase Date: Thu, 6 Apr 2023 14:09:51 +0000 (-0400) Subject: cmd/compile: minor cleanup to HashDebugPos X-Git-Tag: go1.21rc1~991 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=42866e566a4586d7a39758c7186fbcc4678ec97d;p=gostls13.git cmd/compile: minor cleanup to HashDebugPos 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 TryBot-Result: Gopher Robot Reviewed-by: Keith Randall Reviewed-by: Keith Randall --- diff --git a/src/cmd/compile/internal/base/flag.go b/src/cmd/compile/internal/base/flag.go index d9ce42255b..9b6caf5626 100644 --- a/src/cmd/compile/internal/base/flag.go +++ b/src/cmd/compile/internal/base/flag.go @@ -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. diff --git a/src/cmd/compile/internal/base/hashdebug.go b/src/cmd/compile/internal/base/hashdebug.go index 1322768b41..6276abe4fd 100644 --- a/src/cmd/compile/internal/base/hashdebug.go +++ b/src/cmd/compile/internal/base/hashdebug.go @@ -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 { diff --git a/src/cmd/compile/internal/loopvar/loopvar.go b/src/cmd/compile/internal/loopvar/loopvar.go index c92b9d61ea..ce0c41c585 100644 --- a/src/cmd/compile/internal/loopvar/loopvar.go +++ b/src/cmd/compile/internal/loopvar/loopvar.go @@ -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) } } diff --git a/src/cmd/compile/internal/ssa/func.go b/src/cmd/compile/internal/ssa/func.go index ba3d1e589e..f106cdd0b9 100644 --- a/src/cmd/compile/internal/ssa/func.go +++ b/src/cmd/compile/internal/ssa/func.go @@ -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) }