]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: allow disable of PGO function value devirtualization with flag
authorMichael Pratt <mpratt@google.com>
Thu, 16 Nov 2023 18:00:55 +0000 (13:00 -0500)
committerMichael Pratt <mpratt@google.com>
Thu, 16 Nov 2023 21:31:12 +0000 (21:31 +0000)
Extend the pgodevirtualize debug flag to distinguish interface and
function devirtualization. Setting 1 keeps interface devirtualization
enabled but disables function value devirtualization.

For #64209.

Change-Id: I33aa7eb95ca0bdb215256d8c7cc8f9dac53ae30e
Reviewed-on: https://go-review.googlesource.com/c/go/+/543115
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

src/cmd/compile/internal/base/debug.go
src/cmd/compile/internal/base/flag.go
src/cmd/compile/internal/devirtualize/pgo.go

index 9d0dc3f4a692f42c22f8c7d4a953a177bfe6d427..a85f0139fc3b48f254641eaf7aa87b4beaf31f01 100644 (file)
@@ -61,7 +61,7 @@ type DebugFlags struct {
        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"`
-       PGODevirtualize       int    `help:"enable profile-guided devirtualization" concurrent:"ok"`
+       PGODevirtualize       int    `help:"enable profile-guided devirtualization; 0 to disable, 1 to enable interface devirtualization, 2 to enable function devirtualization" concurrent:"ok"`
        RangeFuncCheck        int    `help:"insert code to check behavior of range iterator functions" concurrent:"ok"`
        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 d436665129646fb09b03a400f121cfd952845da9..e2e15c3c9c45d64afb691128a23a529c0c8e4ac4 100644 (file)
@@ -179,7 +179,7 @@ func ParseFlags() {
        Debug.InlFuncsWithClosures = 1
        Debug.InlStaticInit = 1
        Debug.PGOInline = 1
-       Debug.PGODevirtualize = 1
+       Debug.PGODevirtualize = 2
        Debug.SyncFrames = -1 // disable sync markers by default
        Debug.ZeroCopy = 1
        Debug.RangeFuncCheck = 1
index 7b6c8ba0c074aeb5c221dc9965d65d9b11185db3..05b37d6be62d778c370a39145ea4938558aeac4d 100644 (file)
@@ -194,6 +194,10 @@ func ProfileGuided(fn *ir.Func, p *pgo.Profile) {
 // ir.Node if call was devirtualized, and if so also the callee and weight of
 // the devirtualized edge.
 func maybeDevirtualizeInterfaceCall(p *pgo.Profile, fn *ir.Func, call *ir.CallExpr) (ir.Node, *ir.Func, int64) {
+       if base.Debug.PGODevirtualize < 1 {
+               return nil, nil, 0
+       }
+
        // Bail if we do not have a hot callee.
        callee, weight := findHotConcreteInterfaceCallee(p, fn, call)
        if callee == nil {
@@ -220,6 +224,10 @@ func maybeDevirtualizeInterfaceCall(p *pgo.Profile, fn *ir.Func, call *ir.CallEx
 // ir.Node if call was devirtualized, and if so also the callee and weight of
 // the devirtualized edge.
 func maybeDevirtualizeFunctionCall(p *pgo.Profile, fn *ir.Func, call *ir.CallExpr) (ir.Node, *ir.Func, int64) {
+       if base.Debug.PGODevirtualize < 2 {
+               return nil, nil, 0
+       }
+
        // Bail if this is a direct call; no devirtualization necessary.
        callee := pgo.DirectCallee(call.Fun)
        if callee != nil {