cmd/compile:  flag "-d=dumpptrs" to print Node ptrs in Dump output

The printing of the ptr values can mean that two dump outputs can't easily be
compared for the identical structure, so adding the "-d=dumpptrs" option to make
printing of Node pointer values be an option.

Change-Id: I0e92b02f069e9de2e6fa036a7841645d13cdd7a9
Reviewed-on: https://go-review.googlesource.com/c/go/+/271339
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
diff --git a/src/cmd/compile/internal/gc/fmt.go b/src/cmd/compile/internal/gc/fmt.go
index 240b09b..f92f5d0 100644
--- a/src/cmd/compile/internal/gc/fmt.go
+++ b/src/cmd/compile/internal/gc/fmt.go
@@ -419,13 +419,15 @@
 func (n *Node) jconv(s fmt.State, flag FmtFlag) {
 	c := flag & FmtShort
 
-	// Useful to see which nodes in an AST printout are actually identical
-	fmt.Fprintf(s, " p(%p)", n)
+	// Useful to see which nodes in a Node Dump/dumplist are actually identical
+	if Debug_dumpptrs != 0 {
+		fmt.Fprintf(s, " p(%p)", n)
+	}
 	if c == 0 && n.Name != nil && n.Name.Vargen != 0 {
 		fmt.Fprintf(s, " g(%d)", n.Name.Vargen)
 	}
 
-	if c == 0 && n.Name != nil && n.Name.Defn != nil {
+	if Debug_dumpptrs != 0 && c == 0 && n.Name != nil && n.Name.Defn != nil {
 		// Useful to see where Defn is set and what node it points to
 		fmt.Fprintf(s, " defn(%p)", n.Name.Defn)
 	}
diff --git a/src/cmd/compile/internal/gc/main.go b/src/cmd/compile/internal/gc/main.go
index f0a9132..a6963a3 100644
--- a/src/cmd/compile/internal/gc/main.go
+++ b/src/cmd/compile/internal/gc/main.go
@@ -46,6 +46,7 @@
 	Debug_closure      int
 	Debug_compilelater int
 	debug_dclstack     int
+	Debug_dumpptrs     int
 	Debug_libfuzzer    int
 	Debug_panic        int
 	Debug_slice        int
@@ -75,6 +76,7 @@
 	{"compilelater", "compile functions as late as possible", &Debug_compilelater},
 	{"disablenil", "disable nil checks", &disable_checknil},
 	{"dclstack", "run internal dclstack check", &debug_dclstack},
+	{"dumpptrs", "show Node pointer values in Dump/dumplist output", &Debug_dumpptrs},
 	{"gcprog", "print dump of GC programs", &Debug_gcprog},
 	{"libfuzzer", "coverage instrumentation for libfuzzer", &Debug_libfuzzer},
 	{"nil", "print information about nil checks", &Debug_checknil},