]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: cache the value of environment variable GOSSAFUNC
authorYury Smolsky <yury@smolsky.by>
Tue, 24 Jul 2018 10:04:35 +0000 (13:04 +0300)
committerBrad Fitzpatrick <bradfitz@golang.org>
Wed, 22 Aug 2018 21:16:19 +0000 (21:16 +0000)
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>
src/cmd/compile/internal/gc/main.go
src/cmd/compile/internal/gc/ssa.go

index 3fd89873d17491fde7257517ea9bd80e5ecd0c69..5d074114ec0a5921b7997697ff0215118c2737ca 100644 (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
index 9f9fdc07f8d4ffc7fcb3116cab7c0a594c52b9d0..cabcf17ed1cdc3e6acdc788320bcfa2ead424156 100644 (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.