Skip to content

Commit

Permalink
cmd/compile: define starting block before opening html writer
Browse files Browse the repository at this point in the history
Opening the html writer can fail, and the failure printer wants
to use the entry block's line number. So make sure we set up
the entry block first.

Fixes #40919

Change-Id: I4ffa2839b45a721bbaf04ff84418e8108fa1cc37
Reviewed-on: https://go-review.googlesource.com/c/go/+/249497
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
  • Loading branch information
randall77 committed Aug 20, 2020
1 parent 8ec5a05 commit c57c021
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/cmd/compile/internal/gc/ssa.go
Expand Up @@ -338,16 +338,17 @@ func buildssa(fn *Node, worker int) *ssa.Func {
s.panics = map[funcLine]*ssa.Block{}
s.softFloat = s.config.SoftFloat

// Allocate starting block
s.f.Entry = s.f.NewBlock(ssa.BlockPlain)
s.f.Entry.Pos = fn.Pos

if printssa {
s.f.HTMLWriter = ssa.NewHTMLWriter(ssaDumpFile, s.f, ssaDumpCFG)
// TODO: generate and print a mapping from nodes to values and blocks
dumpSourcesColumn(s.f.HTMLWriter, fn)
s.f.HTMLWriter.WriteAST("AST", astBuf)
}

// Allocate starting block
s.f.Entry = s.f.NewBlock(ssa.BlockPlain)

// Allocate starting values
s.labels = map[string]*ssaLabel{}
s.labeledNodes = map[*Node]*ssaLabel{}
Expand Down

0 comments on commit c57c021

Please sign in to comment.