aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/ssa/func.go
diff options
context:
space:
mode:
authorCherry Zhang <cherryyz@google.com>2021-04-05 20:41:56 -0400
committerCherry Zhang <cherryyz@google.com>2021-04-06 14:15:29 +0000
commitb345a306a0258085b65081cf2dadc238dc7e26ee (patch)
tree004e8fa4922d9185107ea9117ab3d8bf2373de6d /src/cmd/compile/internal/ssa/func.go
parent939b561a6e36d9b3854d860a80c24dc80f01f6be (diff)
downloadgo-b345a306a0258085b65081cf2dadc238dc7e26ee.tar.gz
go-b345a306a0258085b65081cf2dadc238dc7e26ee.zip
cmd/compile: when GOSSAFUNC is set, dump the current pass on crash
When an SSA pass ICEs, it calls f.Fatalf, which terminates the compiler. When GOSSAFUNC is set, the current pass is not written to ssa.html. This CL makes it write ssa.html when it calls Fatalf, for the ease of debugging. Change-Id: I5d55e4258f0693d89c48c0a84984f2f893b0811d Reviewed-on: https://go-review.googlesource.com/c/go/+/307509 Trust: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: David Chase <drchase@google.com>
Diffstat (limited to 'src/cmd/compile/internal/ssa/func.go')
-rw-r--r--src/cmd/compile/internal/ssa/func.go14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/cmd/compile/internal/ssa/func.go b/src/cmd/compile/internal/ssa/func.go
index ebbcea598b..819d7573d6 100644
--- a/src/cmd/compile/internal/ssa/func.go
+++ b/src/cmd/compile/internal/ssa/func.go
@@ -653,7 +653,19 @@ func (f *Func) Frontend() Frontend { return f.f
func (f *Func) Warnl(pos src.XPos, msg string, args ...interface{}) { f.fe.Warnl(pos, msg, args...) }
func (f *Func) Logf(msg string, args ...interface{}) { f.fe.Logf(msg, args...) }
func (f *Func) Log() bool { return f.fe.Log() }
-func (f *Func) Fatalf(msg string, args ...interface{}) { f.fe.Fatalf(f.Entry.Pos, msg, args...) }
+
+func (f *Func) Fatalf(msg string, args ...interface{}) {
+ stats := "crashed"
+ if f.Log() {
+ f.Logf(" pass %s end %s\n", f.pass.name, stats)
+ printFunc(f)
+ }
+ if f.HTMLWriter != nil {
+ f.HTMLWriter.WritePhase(f.pass.name, fmt.Sprintf("%s <span class=\"stats\">%s</span>", f.pass.name, stats))
+ f.HTMLWriter.flushPhases()
+ }
+ f.fe.Fatalf(f.Entry.Pos, msg, args...)
+}
// postorder returns the reachable blocks in f in a postorder traversal.
func (f *Func) postorder() []*Block {