]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: move dumpFileSeq
authorsurechen <surechen17@gmail.com>
Mon, 27 Jul 2020 04:00:19 +0000 (12:00 +0800)
committerKeith Randall <khr@golang.org>
Mon, 17 Aug 2020 21:04:19 +0000 (21:04 +0000)
I noticed that there is a Todo comment here. This variable is only used for filename when dump a function's ssa passes result in details. It is no problem to print a function alone, but may be edited by not only one goroutine if dump multiple functions at the same time. Although it looks only dump one function's ssa passes now. As far as I am concerned this variable can be a member variable of the struct Func. I'm not sure if this change is necessary. Looking forward to your advices, thank you very much.

Change-Id: I35dd7247889e0cc7f19c0b400b597206592dee75
Reviewed-on: https://go-review.googlesource.com/c/go/+/244918
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>

src/cmd/compile/internal/ssa/compile.go
src/cmd/compile/internal/ssa/func.go

index dbdd027716a12b250d73220ed1a55b549f9e19e3..444475d67ab9f0370f2c46d0109cbca261b64c31 100644 (file)
@@ -160,15 +160,12 @@ func Compile(f *Func) {
        phaseName = ""
 }
 
-// TODO: should be a config field
-var dumpFileSeq int
-
 // dumpFile creates a file from the phase name and function name
 // Dumping is done to files to avoid buffering huge strings before
 // output.
 func (f *Func) dumpFile(phaseName string) {
-       dumpFileSeq++
-       fname := fmt.Sprintf("%s_%02d__%s.dump", f.Name, dumpFileSeq, phaseName)
+       f.dumpFileSeq++
+       fname := fmt.Sprintf("%s_%02d__%s.dump", f.Name, int(f.dumpFileSeq), phaseName)
        fname = strings.Replace(fname, " ", "_", -1)
        fname = strings.Replace(fname, "/", "_", -1)
        fname = strings.Replace(fname, ":", "_", -1)
index 4b9189fb3e41c016429752fee842ddb8e9a62398..9e40b6214c140cfa8a25985753b2c918918aa433 100644 (file)
@@ -44,9 +44,10 @@ type Func struct {
        PrintOrHtmlSSA bool           // true if GOSSAFUNC matches, true even if fe.Log() (spew phase results to stdout) is false.
        ruleMatches    map[string]int // number of times countRule was called during compilation for any given string
 
-       scheduled bool // Values in Blocks are in final order
-       laidout   bool // Blocks are ordered
-       NoSplit   bool // true if function is marked as nosplit.  Used by schedule check pass.
+       scheduled   bool  // Values in Blocks are in final order
+       laidout     bool  // Blocks are ordered
+       NoSplit     bool  // true if function is marked as nosplit.  Used by schedule check pass.
+       dumpFileSeq uint8 // the sequence numbers of dump file. (%s_%02d__%s.dump", funcname, dumpFileSeq, phaseName)
 
        // when register allocation is done, maps value ids to locations
        RegAlloc []Location