cmd/compile: allow directory specification for GOSSAFUNC output

This was useful for debugging failures occurring during make.bash.
The added flush also ensures that any hints in the GOSSAFUNC output
are flushed before fatal exit.

The environment variable GOSSADIR specifies where the SSA html debugging
files should be placed.  To avoid collisions, each one is written into
the [package].[functionOrMethod].html, where [package] is the filepath
separator separated package name, function is the function name, and method
is either (*Type).Method, or Type.Method, as appropriate.  Directories
are created as necessary to make this work.

Change-Id: I420927426b618b633bb1ffc51cf0f223b8f6d49c
Reviewed-on: https://go-review.googlesource.com/c/go/+/252338
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
David Chase 2020-08-31 14:29:58 -04:00
parent c78c79f152
commit f4cbf3477f
4 changed files with 29 additions and 5 deletions

View file

@ -47,6 +47,9 @@ func Compile(f *Func) {
stack := make([]byte, 16384)
n := runtime.Stack(stack, false)
stack = stack[:n]
if f.HTMLWriter != nil {
f.HTMLWriter.flushPhases()
}
f.Fatalf("panic during %s while compiling %s:\n\n%v\n\n%s\n", phaseName, f.Name, err, stack)
}
}()
@ -201,6 +204,13 @@ func (p *pass) addDump(s string) {
p.dump[s] = true
}
func (p *pass) String() string {
if p == nil {
return "nil pass"
}
return p.name
}
// Run consistency checker between each phase
var (
checkEnabled = false