Skip to content

Commit 7c2cd0b

Browse files
prattmicgopherbot
authored andcommitted
cmd/compile: replace -d=pgoinline with -d=pgodebug
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 golang#59959. Change-Id: I9770ff1f0d132dfa3cd417018a887a1bd5555bba Reviewed-on: https://go-review.googlesource.com/c/go/+/494716 Auto-Submit: Michael Pratt <[email protected]> Run-TryBot: Michael Pratt <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Cherry Mui <[email protected]>
1 parent 13e9696 commit 7c2cd0b

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

src/cmd/compile/internal/base/debug.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,10 @@ type DebugFlags struct {
5050
WB int `help:"print information about write barriers"`
5151
ABIWrap int `help:"print information about ABI wrapper generation"`
5252
MayMoreStack string `help:"call named function before all stack growth checks" concurrent:"ok"`
53+
PGODebug int `help:"debug profile-guided optimizations"`
54+
PGOInline int `help:"enable profile-guided inlining" concurrent:"ok"`
5355
PGOInlineCDFThreshold string `help:"cumulative threshold percentage for determining call sites as hot candidates for inlining" concurrent:"ok"`
5456
PGOInlineBudget int `help:"inline budget for hot functions" concurrent:"ok"`
55-
PGOInline int `help:"debug profile-guided inlining"`
5657
WrapGlobalMapDbg int `help:"debug trace output for global map init wrapping"`
5758
WrapGlobalMapCtl int `help:"global map init wrap control (0 => default, 1 => off, 2 => stress mode, no size cutoff)"`
5859

src/cmd/compile/internal/base/flag.go

+1
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ func ParseFlags() {
168168
Debug.ConcurrentOk = true
169169
Debug.InlFuncsWithClosures = 1
170170
Debug.InlStaticInit = 1
171+
Debug.PGOInline = 1
171172
Debug.SyncFrames = -1 // disable sync markers by default
172173

173174
Debug.Checkptr = -1 // so we can tell whether it is set explicitly

src/cmd/compile/internal/inline/inl.go

+10-6
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func pgoInlinePrologue(p *pgo.Profile, decls []ir.Node) {
8787
}
8888
var hotCallsites []pgo.NodeMapKey
8989
inlineHotCallSiteThresholdPercent, hotCallsites = hotNodesFromCDF(p)
90-
if base.Debug.PGOInline > 0 {
90+
if base.Debug.PGODebug > 0 {
9191
fmt.Printf("hot-callsite-thres-from-CDF=%v\n", inlineHotCallSiteThresholdPercent)
9292
}
9393

@@ -107,7 +107,7 @@ func pgoInlinePrologue(p *pgo.Profile, decls []ir.Node) {
107107
}
108108
}
109109

110-
if base.Debug.PGOInline >= 2 {
110+
if base.Debug.PGODebug >= 2 {
111111
fmt.Printf("hot-cg before inline in dot format:")
112112
p.PrintWeightedCallGraphDOT(inlineHotCallSiteThresholdPercent)
113113
}
@@ -156,6 +156,10 @@ func hotNodesFromCDF(p *pgo.Profile) (float64, []pgo.NodeMapKey) {
156156

157157
// InlinePackage finds functions that can be inlined and clones them before walk expands them.
158158
func InlinePackage(p *pgo.Profile) {
159+
if base.Debug.PGOInline == 0 {
160+
p = nil
161+
}
162+
159163
InlineDecls(p, typecheck.Target.Decls, true)
160164

161165
// Perform a garbage collection of hidden closures functions that
@@ -365,7 +369,7 @@ func CanInline(fn *ir.Func, profile *pgo.Profile) {
365369
if n, ok := profile.WeightedCG.IRNodes[ir.LinkFuncName(fn)]; ok {
366370
if _, ok := candHotCalleeMap[n]; ok {
367371
budget = int32(inlineHotMaxBudget)
368-
if base.Debug.PGOInline > 0 {
372+
if base.Debug.PGODebug > 0 {
369373
fmt.Printf("hot-node enabled increased budget=%v for func=%v\n", budget, ir.PkgFuncName(fn))
370374
}
371375
}
@@ -557,7 +561,7 @@ func (v *hairyVisitor) doNode(n ir.Node) bool {
557561
lineOffset := pgo.NodeLineOffset(n, fn)
558562
csi := pgo.CallSiteInfo{LineOffset: lineOffset, Caller: v.curFunc}
559563
if _, o := candHotEdgeMap[csi]; o {
560-
if base.Debug.PGOInline > 0 {
564+
if base.Debug.PGODebug > 0 {
561565
fmt.Printf("hot-callsite identified at line=%v for func=%v\n", ir.Line(n), ir.PkgFuncName(v.curFunc))
562566
}
563567
}
@@ -991,7 +995,7 @@ func inlineCostOK(n *ir.CallExpr, caller, callee *ir.Func, bigCaller bool) (bool
991995
// Hot
992996

993997
if bigCaller {
994-
if base.Debug.PGOInline > 0 {
998+
if base.Debug.PGODebug > 0 {
995999
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))
9961000
}
9971001
return false, maxCost
@@ -1001,7 +1005,7 @@ func inlineCostOK(n *ir.CallExpr, caller, callee *ir.Func, bigCaller bool) (bool
10011005
return false, inlineHotMaxBudget
10021006
}
10031007

1004-
if base.Debug.PGOInline > 0 {
1008+
if base.Debug.PGODebug > 0 {
10051009
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))
10061010
}
10071011

0 commit comments

Comments
 (0)