aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/inline
diff options
context:
space:
mode:
authorThan McIntosh <thanm@google.com>2022-04-19 19:41:40 -0400
committerThan McIntosh <thanm@google.com>2022-09-27 10:29:51 +0000
commit072c7d4969862c84430cc2daef20a8f7f3ba78a2 (patch)
treef0cb83f688a4a5bc18168f1e1e2a72f37999a783 /src/cmd/compile/internal/inline
parent361f5eba9f9e9902226e7edac76646253b7025e4 (diff)
downloadgo-072c7d4969862c84430cc2daef20a8f7f3ba78a2.tar.xz
cmd/compile,cmd/link: hooks for identifying coverage counters
Add a new "coverage counter" classification for variables to be used for storing code coverage counter values (somewhat in the same way that we identify fuzzer counters). Tagging such variables allows us to aggregate them in the linker, and to treat updates specially. Updates #51430. Change-Id: Ib49fb05736ffece98bcc2f7a7c37e991b7f67bbb Reviewed-on: https://go-review.googlesource.com/c/go/+/401235 Reviewed-by: David Chase <drchase@google.com> Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/inline')
-rw-r--r--src/cmd/compile/internal/inline/inl.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/inline/inl.go b/src/cmd/compile/internal/inline/inl.go
index a7fd704b85..14adbf5d43 100644
--- a/src/cmd/compile/internal/inline/inl.go
+++ b/src/cmd/compile/internal/inline/inl.go
@@ -37,6 +37,7 @@ import (
"cmd/compile/internal/typecheck"
"cmd/compile/internal/types"
"cmd/internal/obj"
+ "cmd/internal/objabi"
"cmd/internal/src"
)
@@ -471,6 +472,28 @@ func (v *hairyVisitor) doNode(n ir.Node) bool {
}
}
}
+
+ case ir.OAS:
+ // Special case for coverage counter updates and coverage
+ // function registrations. Although these correspond to real
+ // operations, we treat them as zero cost for the moment. This
+ // is primarily due to the existence of tests that are
+ // sensitive to inlining-- if the insertion of coverage
+ // instrumentation happens to tip a given function over the
+ // threshold and move it from "inlinable" to "not-inlinable",
+ // this can cause changes in allocation behavior, which can
+ // then result in test failures (a good example is the
+ // TestAllocations in crypto/ed25519).
+ n := n.(*ir.AssignStmt)
+ if n.X.Op() == ir.OINDEX {
+ n := n.X.(*ir.IndexExpr)
+ if n.X.Op() == ir.ONAME && n.X.Type().IsArray() {
+ n := n.X.(*ir.Name)
+ if n.Linksym().Type == objabi.SCOVERAGE_COUNTER {
+ return false
+ }
+ }
+ }
}
v.budget--