]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: replace -d=pgoinline with -d=pgodebug
authorMichael Pratt <mpratt@google.com>
Fri, 12 May 2023 19:36:37 +0000 (15:36 -0400)
committerGopher Robot <gobot@golang.org>
Mon, 22 May 2023 15:35:03 +0000 (15:35 +0000)
We will soon have PGO specialization. It doesn't make sense for the
debug flag to have inline in the name, so rename it to pgodebug.

pgoinline is now a flag that can be used to disable PGO inlining.
Devirtualization will have a similar debug flag.

For #59959.

Change-Id: I9770ff1f0d132dfa3cd417018a887a1bd5555bba
Reviewed-on: https://go-review.googlesource.com/c/go/+/494716
Auto-Submit: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
src/cmd/compile/internal/base/debug.go
src/cmd/compile/internal/base/flag.go
src/cmd/compile/internal/inline/inl.go

index ec20b181349f7d1c0698484164120071be54d0cf..e217b3e9b08ade4145b7807a298a637640c539c9 100644 (file)
@@ -50,9 +50,10 @@ type DebugFlags struct {
        WB                    int    `help:"print information about write barriers"`
        ABIWrap               int    `help:"print information about ABI wrapper generation"`
        MayMoreStack          string `help:"call named function before all stack growth checks" concurrent:"ok"`
+       PGODebug              int    `help:"debug profile-guided optimizations"`
+       PGOInline             int    `help:"enable profile-guided inlining" concurrent:"ok"`
        PGOInlineCDFThreshold string `help:"cumulative threshold percentage for determining call sites as hot candidates for inlining" concurrent:"ok"`
        PGOInlineBudget       int    `help:"inline budget for hot functions" concurrent:"ok"`
-       PGOInline             int    `help:"debug profile-guided inlining"`
        WrapGlobalMapDbg      int    `help:"debug trace output for global map init wrapping"`
        WrapGlobalMapCtl      int    `help:"global map init wrap control (0 => default, 1 => off, 2 => stress mode, no size cutoff)"`
 
index 9305aaa88af4c557e3d0a73156a9976e7dd625c3..f1656fc98c590423084070d38d38cd0dcf38ef22 100644 (file)
@@ -168,6 +168,7 @@ func ParseFlags() {
        Debug.ConcurrentOk = true
        Debug.InlFuncsWithClosures = 1
        Debug.InlStaticInit = 1
+       Debug.PGOInline = 1
        Debug.SyncFrames = -1 // disable sync markers by default
 
        Debug.Checkptr = -1 // so we can tell whether it is set explicitly
index f8b5c4abae510639ba8a5febe8d54d5f488636d5..ff7e929ef489d8fde49d1a41a00c793bcf426195 100644 (file)
@@ -87,7 +87,7 @@ func pgoInlinePrologue(p *pgo.Profile, decls []ir.Node) {
        }
        var hotCallsites []pgo.NodeMapKey
        inlineHotCallSiteThresholdPercent, hotCallsites = hotNodesFromCDF(p)
-       if base.Debug.PGOInline > 0 {
+       if base.Debug.PGODebug > 0 {
                fmt.Printf("hot-callsite-thres-from-CDF=%v\n", inlineHotCallSiteThresholdPercent)
        }
 
@@ -107,7 +107,7 @@ func pgoInlinePrologue(p *pgo.Profile, decls []ir.Node) {
                }
        }
 
-       if base.Debug.PGOInline >= 2 {
+       if base.Debug.PGODebug >= 2 {
                fmt.Printf("hot-cg before inline in dot format:")
                p.PrintWeightedCallGraphDOT(inlineHotCallSiteThresholdPercent)
        }
@@ -156,6 +156,10 @@ func hotNodesFromCDF(p *pgo.Profile) (float64, []pgo.NodeMapKey) {
 
 // InlinePackage finds functions that can be inlined and clones them before walk expands them.
 func InlinePackage(p *pgo.Profile) {
+       if base.Debug.PGOInline == 0 {
+               p = nil
+       }
+
        InlineDecls(p, typecheck.Target.Decls, true)
 
        // Perform a garbage collection of hidden closures functions that
@@ -365,7 +369,7 @@ func CanInline(fn *ir.Func, profile *pgo.Profile) {
                if n, ok := profile.WeightedCG.IRNodes[ir.LinkFuncName(fn)]; ok {
                        if _, ok := candHotCalleeMap[n]; ok {
                                budget = int32(inlineHotMaxBudget)
-                               if base.Debug.PGOInline > 0 {
+                               if base.Debug.PGODebug > 0 {
                                        fmt.Printf("hot-node enabled increased budget=%v for func=%v\n", budget, ir.PkgFuncName(fn))
                                }
                        }
@@ -557,7 +561,7 @@ func (v *hairyVisitor) doNode(n ir.Node) bool {
                                lineOffset := pgo.NodeLineOffset(n, fn)
                                csi := pgo.CallSiteInfo{LineOffset: lineOffset, Caller: v.curFunc}
                                if _, o := candHotEdgeMap[csi]; o {
-                                       if base.Debug.PGOInline > 0 {
+                                       if base.Debug.PGODebug > 0 {
                                                fmt.Printf("hot-callsite identified at line=%v for func=%v\n", ir.Line(n), ir.PkgFuncName(v.curFunc))
                                        }
                                }
@@ -991,7 +995,7 @@ func inlineCostOK(n *ir.CallExpr, caller, callee *ir.Func, bigCaller bool) (bool
        // Hot
 
        if bigCaller {
-               if base.Debug.PGOInline > 0 {
+               if base.Debug.PGODebug > 0 {
                        fmt.Printf("hot-big check disallows inlining for call %s (cost %d) at %v in big function %s\n", ir.PkgFuncName(callee), callee.Inl.Cost, ir.Line(n), ir.PkgFuncName(caller))
                }
                return false, maxCost
@@ -1001,7 +1005,7 @@ func inlineCostOK(n *ir.CallExpr, caller, callee *ir.Func, bigCaller bool) (bool
                return false, inlineHotMaxBudget
        }
 
-       if base.Debug.PGOInline > 0 {
+       if base.Debug.PGODebug > 0 {
                fmt.Printf("hot-budget check allows inlining for call %s (cost %d) at %v in function %s\n", ir.PkgFuncName(callee), callee.Inl.Cost, ir.Line(n), ir.PkgFuncName(caller))
        }