cmd/compile: also check package.function for GOSSAFUNC match

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>
diff --git a/src/cmd/compile/internal/gc/ssa.go b/src/cmd/compile/internal/gc/ssa.go
index c8fb013..104dd40 100644
--- a/src/cmd/compile/internal/gc/ssa.go
+++ b/src/cmd/compile/internal/gc/ssa.go
@@ -295,7 +295,10 @@
 // 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{}