From e34f660a52b810e7f4d4a186c7502324c67390ea Mon Sep 17 00:00:00 2001 From: Yury Smolsky Date: Tue, 24 Jul 2018 13:04:35 +0300 Subject: [PATCH] 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 TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick --- src/cmd/compile/internal/gc/main.go | 2 ++ src/cmd/compile/internal/gc/ssa.go | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/cmd/compile/internal/gc/main.go b/src/cmd/compile/internal/gc/main.go index 3fd89873d1..5d074114ec 100644 --- a/src/cmd/compile/internal/gc/main.go +++ b/src/cmd/compile/internal/gc/main.go @@ -427,6 +427,8 @@ func Main(archInit func(*Arch)) { Debug['l'] = 1 - Debug['l'] } + ssaDump = os.Getenv("GOSSAFUNC") + trackScopes = flagDWARF Widthptr = thearch.LinkArch.PtrSize diff --git a/src/cmd/compile/internal/gc/ssa.go b/src/cmd/compile/internal/gc/ssa.go index 9f9fdc07f8..cabcf17ed1 100644 --- a/src/cmd/compile/internal/gc/ssa.go +++ b/src/cmd/compile/internal/gc/ssa.go @@ -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. -- 2.48.1