]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: restore missing columns in ssa.html
authorBradford Lamson-Scribner <brad.lamson@gmail.com>
Sun, 5 Apr 2020 22:12:05 +0000 (16:12 -0600)
committerJosh Bleecher Snyder <josharian@gmail.com>
Sun, 5 Apr 2020 23:23:03 +0000 (23:23 +0000)
If the final pass(es) are identical during ssa.html generation,
they are persisted in-memory as "pendingPhases" but never get
written as a column in the html. This change flushes those
in-memory phases.

Fixes #38242

Change-Id: Id13477dcbe7b419a818bb457861b2422ba5ef4bc
Reviewed-on: https://go-review.googlesource.com/c/go/+/227182
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

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

index 3da3b8985f518787ea8c28f3f4ba4988d0518dfa..2dbe9cf405242102edfa40bb552f3207e14cbdc3 100644 (file)
@@ -136,6 +136,11 @@ func Compile(f *Func) {
                }
        }
 
+       if f.HTMLWriter != nil {
+               // Ensure we write any pending phases to the html
+               f.HTMLWriter.flushPhases()
+       }
+
        if f.ruleMatches != nil {
                var keys []string
                for key := range f.ruleMatches {
index 1b083917dc341e3245b48d968af26e3dbed02f3d..f39106f45028cb5604561ddc7a470a5f43e9175f 100644 (file)
@@ -774,14 +774,28 @@ func (w *HTMLWriter) WritePhase(phase, title string) {
        w.pendingPhases = append(w.pendingPhases, phase)
        w.pendingTitles = append(w.pendingTitles, title)
        if !bytes.Equal(hash, w.prevHash) {
-               phases := strings.Join(w.pendingPhases, "  +  ")
-               w.WriteMultiTitleColumn(phases, w.pendingTitles, fmt.Sprintf("hash-%x", hash), w.Func.HTML(phase, w.dot))
-               w.pendingPhases = w.pendingPhases[:0]
-               w.pendingTitles = w.pendingTitles[:0]
+               w.flushPhases()
        }
        w.prevHash = hash
 }
 
+// flushPhases collects any pending phases and titles, writes them to the html, and resets the pending slices.
+func (w *HTMLWriter) flushPhases() {
+       phaseLen := len(w.pendingPhases)
+       if phaseLen == 0 {
+               return
+       }
+       phases := strings.Join(w.pendingPhases, "  +  ")
+       w.WriteMultiTitleColumn(
+               phases,
+               w.pendingTitles,
+               fmt.Sprintf("hash-%x", w.prevHash),
+               w.Func.HTML(w.pendingPhases[phaseLen-1], w.dot),
+       )
+       w.pendingPhases = w.pendingPhases[:0]
+       w.pendingTitles = w.pendingTitles[:0]
+}
+
 // FuncLines contains source code for a function to be displayed
 // in sources column.
 type FuncLines struct {