1
0
mirror of https://github.com/golang/go synced 2024-11-12 09:20:22 -07:00

cmd/compile: cache the value of environment variable GOSSAFUNC

Store the value of GOSSAFUNC in a global variable to avoid
multiple calls to os.Getenv from gc.buildssa and gc.mkinlcall1.
The latter is implemented in the CL 126606.

Updates #25942

Change-Id: I58caaef2fee23694d80dc5a561a2e809bf077fa4
Reviewed-on: https://go-review.googlesource.com/126604
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Yury Smolsky 2018-07-24 13:04:35 +03:00 committed by Brad Fitzpatrick
parent d35135b9da
commit e34f660a52
2 changed files with 7 additions and 2 deletions

View File

@ -427,6 +427,8 @@ func Main(archInit func(*Arch)) {
Debug['l'] = 1 - Debug['l']
}
ssaDump = os.Getenv("GOSSAFUNC")
trackScopes = flagDWARF
Widthptr = thearch.LinkArch.PtrSize

View File

@ -23,6 +23,9 @@ import (
var ssaConfig *ssa.Config
var ssaCaches []ssa.Cache
var ssaDump string // early copy of $GOSSAFUNC; the func name to dump output for
const ssaDumpFile = "ssa.html"
func initssaconfig() {
types_ := ssa.NewTypes()
@ -103,7 +106,7 @@ func initssaconfig() {
// worker indicates which of the backend workers is doing the processing.
func buildssa(fn *Node, worker int) *ssa.Func {
name := fn.funcname()
printssa := name == os.Getenv("GOSSAFUNC")
printssa := name == ssaDump
if printssa {
fmt.Println("generating SSA for", name)
dumplist("buildssa-enter", fn.Func.Enter)
@ -141,7 +144,7 @@ func buildssa(fn *Node, worker int) *ssa.Func {
s.softFloat = s.config.SoftFloat
if printssa {
s.f.HTMLWriter = ssa.NewHTMLWriter("ssa.html", s.f.Frontend(), name)
s.f.HTMLWriter = ssa.NewHTMLWriter(ssaDumpFile, s.f.Frontend(), name)
// TODO: generate and print a mapping from nodes to values and blocks
// Read sources for a function fn and format into a column.