mirror of
https://github.com/golang/go
synced 2024-11-18 18:14:43 -07:00
cmd/compile/internal/inlheur: minor debug trace changes
Minor changes to debug tracing and to the -d=dumpinlfuncprops debug flag implementation. Change-Id: Ibaefd489c94675ac7f5a04ec0331b7f888c15a49 Reviewed-on: https://go-review.googlesource.com/c/go/+/521818 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
eac1f3e461
commit
a9cfbec17b
@ -7,6 +7,7 @@ package inlheur
|
||||
import (
|
||||
"cmd/compile/internal/base"
|
||||
"cmd/compile/internal/ir"
|
||||
"cmd/compile/internal/types"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"internal/goexperiment"
|
||||
@ -150,8 +151,8 @@ func UnitTesting() bool {
|
||||
// primarily in unit testing.
|
||||
func DumpFuncProps(fn *ir.Func, dumpfile string, canInline func(*ir.Func)) {
|
||||
if fn != nil {
|
||||
enableDebugTraceIfEnv()
|
||||
dmp := func(fn *ir.Func) {
|
||||
|
||||
if !goexperiment.NewInliner {
|
||||
ScoreCalls(fn)
|
||||
}
|
||||
@ -164,6 +165,7 @@ func DumpFuncProps(fn *ir.Func, dumpfile string, canInline func(*ir.Func)) {
|
||||
dmp(clo.Func)
|
||||
}
|
||||
})
|
||||
disableDebugTrace()
|
||||
} else {
|
||||
emitDumpToFile(dumpfile)
|
||||
}
|
||||
@ -174,7 +176,18 @@ func DumpFuncProps(fn *ir.Func, dumpfile string, canInline func(*ir.Func)) {
|
||||
// definition line, and due to generics we need to account for the
|
||||
// possibility that several ir.Func's will have the same def line.
|
||||
func emitDumpToFile(dumpfile string) {
|
||||
outf, err := os.OpenFile(dumpfile, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
|
||||
mode := os.O_WRONLY | os.O_CREATE | os.O_TRUNC
|
||||
if dumpfile[0] == '+' {
|
||||
dumpfile = dumpfile[1:]
|
||||
mode = os.O_WRONLY | os.O_APPEND | os.O_CREATE
|
||||
}
|
||||
if dumpfile[0] == '%' {
|
||||
dumpfile = dumpfile[1:]
|
||||
d, b := filepath.Dir(dumpfile), filepath.Base(dumpfile)
|
||||
ptag := strings.ReplaceAll(types.LocalPkg.Path, "/", ":")
|
||||
dumpfile = d + "/" + ptag + "." + b
|
||||
}
|
||||
outf, err := os.OpenFile(dumpfile, mode, 0644)
|
||||
if err != nil {
|
||||
base.Fatalf("opening function props dump file %q: %v\n", dumpfile, err)
|
||||
}
|
||||
@ -219,12 +232,9 @@ func captureFuncDumpEntry(fn *ir.Func, canInline func(*ir.Func)) {
|
||||
return
|
||||
}
|
||||
fih, ok := fpmap[fn]
|
||||
if goexperiment.NewInliner {
|
||||
// Props object should already be present.
|
||||
if !ok {
|
||||
panic("unexpected missing props")
|
||||
}
|
||||
} else {
|
||||
// Props object should already be present, unless this is a
|
||||
// directly recursive routine.
|
||||
if !ok {
|
||||
AnalyzeFunc(fn, canInline)
|
||||
fih = fpmap[fn]
|
||||
if fn.Inl != nil && fn.Inl.Properties == "" {
|
||||
|
Loading…
Reference in New Issue
Block a user