aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBradford Lamson-Scribner <brad.lamson@gmail.com>2020-04-05 16:12:05 -0600
committerJosh Bleecher Snyder <josharian@gmail.com>2020-04-05 23:23:03 +0000
commit763bd58b19a3aea9760cb8c8326dabf78653db68 (patch)
tree1338ff52b0f25e59549787f587e4569cdf7cd21b
parent281d41cb400fdc3f5581bb0e479f2e9ff02fe833 (diff)
downloadgo-763bd58b19a3aea9760cb8c8326dabf78653db68.tar.gz
go-763bd58b19a3aea9760cb8c8326dabf78653db68.zip
cmd/compile: restore missing columns in ssa.html
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>
-rw-r--r--src/cmd/compile/internal/ssa/compile.go5
-rw-r--r--src/cmd/compile/internal/ssa/html.go22
2 files changed, 23 insertions, 4 deletions
diff --git a/src/cmd/compile/internal/ssa/compile.go b/src/cmd/compile/internal/ssa/compile.go
index 3da3b8985f..2dbe9cf405 100644
--- a/src/cmd/compile/internal/ssa/compile.go
+++ b/src/cmd/compile/internal/ssa/compile.go
@@ -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 {
diff --git a/src/cmd/compile/internal/ssa/html.go b/src/cmd/compile/internal/ssa/html.go
index 1b083917dc..f39106f450 100644
--- a/src/cmd/compile/internal/ssa/html.go
+++ b/src/cmd/compile/internal/ssa/html.go
@@ -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 {