From: thepudds Date: Fri, 27 Jun 2025 22:46:27 +0000 (-0400) Subject: cmd/compile/internal/escape: stop disabling literal allocation optimizations when... X-Git-Tag: go1.25rc2~2^2~8 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=479b51ee1f;p=gostls13.git cmd/compile/internal/escape: stop disabling literal allocation optimizations when coverage is enabled CL 649079 and CL 649035 updated escape analysis to rewrite certain expressions in OMAKE and OCONVIFACE nodes as optimizations to reduce user allocations. Part of the change in CL 649079 disabled those optimzations when coverage instrumentation was enabled under an incorrect possible theory of how those optimizations might be "expected" to change coverage results -- in particular, the cover_build_pkg_select.txt testscript failed with different coverage results. I now realize that the proper explanation is that my fix in CL 684116 was needed. Now that CL 684116 is merged, we should no longer disable these optimizations when coverage is enabled, which is what this CL does. This has not been reported as a problem to my knowledge, but without this CL, one could imagine for example a test using testing.AllocsPerRun might start failing when coverage was enabled if the result relied on these optimizations. As expected, if we place this CL just before the necessary fix in CL 684116, the cover_build_pkg_select.txt testscript fails with a changed coverage result. If we place this CL just after CL 684116, the test passes, also as expected. Updates #71359 Change-Id: Ib5ff00c267acd85dd423c238d177e91a4d881f9e Reviewed-on: https://go-review.googlesource.com/c/go/+/684777 Reviewed-by: David Chase LUCI-TryBot-Result: Go LUCI Reviewed-by: Cherry Mui --- diff --git a/src/cmd/compile/internal/escape/escape.go b/src/cmd/compile/internal/escape/escape.go index a39d6b49a6..600b986d3f 100644 --- a/src/cmd/compile/internal/escape/escape.go +++ b/src/cmd/compile/internal/escape/escape.go @@ -534,10 +534,6 @@ func (b *batch) rewriteWithLiterals(n ir.Node, fn *ir.Func) { if n.Op() != ir.OMAKESLICE && n.Op() != ir.OCONVIFACE { return } - if base.Flag.Cfg.CoverageInfo != nil { - // Avoid altering coverage results. - return - } // Look up a cached ReassignOracle for the function, lazily computing one if needed. ro := b.reassignOracle(fn)