Skip to content

Commit e34f660

Browse files
Yury Smolskybradfitz
Yury Smolsky
authored andcommitted
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 <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent d35135b commit e34f660

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/cmd/compile/internal/gc/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,8 @@ func Main(archInit func(*Arch)) {
427427
Debug['l'] = 1 - Debug['l']
428428
}
429429

430+
ssaDump = os.Getenv("GOSSAFUNC")
431+
430432
trackScopes = flagDWARF
431433

432434
Widthptr = thearch.LinkArch.PtrSize

src/cmd/compile/internal/gc/ssa.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ import (
2323
var ssaConfig *ssa.Config
2424
var ssaCaches []ssa.Cache
2525

26+
var ssaDump string // early copy of $GOSSAFUNC; the func name to dump output for
27+
const ssaDumpFile = "ssa.html"
28+
2629
func initssaconfig() {
2730
types_ := ssa.NewTypes()
2831

@@ -103,7 +106,7 @@ func initssaconfig() {
103106
// worker indicates which of the backend workers is doing the processing.
104107
func buildssa(fn *Node, worker int) *ssa.Func {
105108
name := fn.funcname()
106-
printssa := name == os.Getenv("GOSSAFUNC")
109+
printssa := name == ssaDump
107110
if printssa {
108111
fmt.Println("generating SSA for", name)
109112
dumplist("buildssa-enter", fn.Func.Enter)
@@ -141,7 +144,7 @@ func buildssa(fn *Node, worker int) *ssa.Func {
141144
s.softFloat = s.config.SoftFloat
142145

143146
if printssa {
144-
s.f.HTMLWriter = ssa.NewHTMLWriter("ssa.html", s.f.Frontend(), name)
147+
s.f.HTMLWriter = ssa.NewHTMLWriter(ssaDumpFile, s.f.Frontend(), name)
145148
// TODO: generate and print a mapping from nodes to values and blocks
146149

147150
// Read sources for a function fn and format into a column.

0 commit comments

Comments
 (0)