import (
"cmd/compile/internal/base"
"cmd/compile/internal/ir"
+ "cmd/compile/internal/types"
"encoding/json"
"fmt"
"internal/goexperiment"
// 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)
}
dmp(clo.Func)
}
})
+ disableDebugTrace()
} else {
emitDumpToFile(dumpfile)
}
// 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)
}
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 == "" {