]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: also check package.function for GOSSAFUNC match
authorDavid Chase <drchase@google.com>
Tue, 25 Aug 2020 02:57:01 +0000 (22:57 -0400)
committerDavid Chase <drchase@google.com>
Tue, 25 Aug 2020 14:51:49 +0000 (14:51 +0000)
Old behavior is still enabled because it doesn't hurt to leave
it in and existing users of this feature (there are dozens of
us!) will not be surprised.  Adding this finer control allows
users to avoid writing ssa.html where they can't, shouldn't, or
just don't want to.

Example, both ways:

$ GOSSAFUNC="(*Reader).Reset" go test -c -o ./a compress/gzip
dumped SSA to bytes/ssa.html
dumped SSA to strings/ssa.html
dumped SSA to bufio/ssa.html
dumped SSA to compress/gzip/ssa.html

$ GOSSAFUNC="compress/gzip.(*Reader).Reset" go test -c -o ./a compress/gzip
dumped SSA to compress/gzip/ssa.html

Updates #40919.

Change-Id: I06b77c3c1d326372a32651570b5dd6e56dfb1d7f
Reviewed-on: https://go-review.googlesource.com/c/go/+/250340
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/gc/ssa.go

index c8fb013ad0a021b3dec61d8ff2d5156a55920f6d..104dd403eab1b7cc19759e50eb15c96e384c704b 100644 (file)
@@ -295,7 +295,10 @@ func (s *state) emitOpenDeferInfo() {
 // worker indicates which of the backend workers is doing the processing.
 func buildssa(fn *Node, worker int) *ssa.Func {
        name := fn.funcname()
-       printssa := name == ssaDump
+       printssa := false
+       if ssaDump != "" { // match either a simple name e.g. "(*Reader).Reset", or a package.name e.g. "compress/gzip.(*Reader).Reset"
+               printssa = name == ssaDump || myimportpath+"."+name == ssaDump
+       }
        var astBuf *bytes.Buffer
        if printssa {
                astBuf = &bytes.Buffer{}