"cmd/compile/internal/inline"
"cmd/compile/internal/ir"
"cmd/compile/internal/logopt"
- "cmd/compile/internal/pgo"
+ "cmd/compile/internal/pgoir"
"cmd/compile/internal/typecheck"
"cmd/compile/internal/types"
"cmd/internal/obj"
//
// The primary benefit of this transformation is enabling inlining of the
// direct call.
-func ProfileGuided(fn *ir.Func, p *pgo.Profile) {
+func ProfileGuided(fn *ir.Func, p *pgoir.Profile) {
ir.CurFunc = fn
name := ir.LinkFuncName(fn)
// Devirtualize interface call if possible and eligible. Returns the new
// 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) {
+func maybeDevirtualizeInterfaceCall(p *pgoir.Profile, fn *ir.Func, call *ir.CallExpr) (ir.Node, *ir.Func, int64) {
if base.Debug.PGODevirtualize < 1 {
return nil, nil, 0
}
// Devirtualize an indirect function call if possible and eligible. Returns the new
// 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) {
+func maybeDevirtualizeFunctionCall(p *pgoir.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)
+ callee := pgoir.DirectCallee(call.Fun)
if callee != nil {
return nil, nil, 0
}
fmt.Printf("%v: should not PGO devirtualize %v: %s\n", ir.Line(fn), ir.FuncName(fn), reason)
}
if logopt.Enabled() {
- logopt.LogOpt(fn.Pos(), ": should not PGO devirtualize function", "pgo-devirtualize", ir.FuncName(fn), reason)
+ logopt.LogOpt(fn.Pos(), ": should not PGO devirtualize function", "pgoir-devirtualize", ir.FuncName(fn), reason)
}
}
}()
// constructCallStat builds an initial CallStat describing this call, for
// logging. If the call is devirtualized, the devirtualization fields should be
// updated.
-func constructCallStat(p *pgo.Profile, fn *ir.Func, name string, call *ir.CallExpr) *CallStat {
+func constructCallStat(p *pgoir.Profile, fn *ir.Func, name string, call *ir.CallExpr) *CallStat {
switch call.Op() {
case ir.OCALLFUNC, ir.OCALLINTER, ir.OCALLMETH:
default:
Caller: name,
}
- offset := pgo.NodeLineOffset(call, fn)
+ offset := pgoir.NodeLineOffset(call, fn)
- hotter := func(e *pgo.IREdge) bool {
+ hotter := func(e *pgoir.IREdge) bool {
if stat.Hottest == "" {
return true
}
case ir.OCALLFUNC:
stat.Interface = false
- callee := pgo.DirectCallee(call.Fun)
+ callee := pgoir.DirectCallee(call.Fun)
if callee != nil {
stat.Direct = true
if stat.Hottest == "" {
// if available, and its edge weight. extraFn can perform additional
// applicability checks on each candidate edge. If extraFn returns false,
// candidate will not be considered a valid callee candidate.
-func findHotConcreteCallee(p *pgo.Profile, caller *ir.Func, call *ir.CallExpr, extraFn func(callerName string, callOffset int, candidate *pgo.IREdge) bool) (*ir.Func, int64) {
+func findHotConcreteCallee(p *pgoir.Profile, caller *ir.Func, call *ir.CallExpr, extraFn func(callerName string, callOffset int, candidate *pgoir.IREdge) bool) (*ir.Func, int64) {
callerName := ir.LinkFuncName(caller)
callerNode := p.WeightedCG.IRNodes[callerName]
- callOffset := pgo.NodeLineOffset(call, caller)
+ callOffset := pgoir.NodeLineOffset(call, caller)
- var hottest *pgo.IREdge
+ var hottest *pgoir.IREdge
// Returns true if e is hotter than hottest.
//
// has arbitrary iteration order, we need to apply additional sort
// criteria when e.Weight == hottest.Weight to ensure we have stable
// selection.
- hotter := func(e *pgo.IREdge) bool {
+ hotter := func(e *pgoir.IREdge) bool {
if hottest == nil {
return true
}
// findHotConcreteInterfaceCallee returns the *ir.Func of the hottest callee of an
// interface call, if available, and its edge weight.
-func findHotConcreteInterfaceCallee(p *pgo.Profile, caller *ir.Func, call *ir.CallExpr) (*ir.Func, int64) {
+func findHotConcreteInterfaceCallee(p *pgoir.Profile, caller *ir.Func, call *ir.CallExpr) (*ir.Func, int64) {
inter, method := interfaceCallRecvTypeAndMethod(call)
- return findHotConcreteCallee(p, caller, call, func(callerName string, callOffset int, e *pgo.IREdge) bool {
+ return findHotConcreteCallee(p, caller, call, func(callerName string, callOffset int, e *pgoir.IREdge) bool {
ctyp := methodRecvType(e.Dst.AST)
if ctyp == nil {
// Not a method.
// findHotConcreteFunctionCallee returns the *ir.Func of the hottest callee of an
// indirect function call, if available, and its edge weight.
-func findHotConcreteFunctionCallee(p *pgo.Profile, caller *ir.Func, call *ir.CallExpr) (*ir.Func, int64) {
+func findHotConcreteFunctionCallee(p *pgoir.Profile, caller *ir.Func, call *ir.CallExpr) (*ir.Func, int64) {
typ := call.Fun.Type().Underlying()
- return findHotConcreteCallee(p, caller, call, func(callerName string, callOffset int, e *pgo.IREdge) bool {
+ return findHotConcreteCallee(p, caller, call, func(callerName string, callOffset int, e *pgoir.IREdge) bool {
ctyp := e.Dst.AST.Type().Underlying()
// If ctyp doesn't match typ it is most likely from a different
"cmd/compile/internal/inline"
"cmd/compile/internal/inline/inlheur"
"cmd/compile/internal/ir"
- "cmd/compile/internal/pgo"
+ "cmd/compile/internal/pgoir"
"cmd/compile/internal/typecheck"
"fmt"
)
// DevirtualizeAndInlinePackage interleaves devirtualization and inlining on
// all functions within pkg.
-func DevirtualizeAndInlinePackage(pkg *ir.Package, profile *pgo.Profile) {
+func DevirtualizeAndInlinePackage(pkg *ir.Package, profile *pgoir.Profile) {
if profile != nil && base.Debug.PGODevirtualize > 0 {
// TODO(mdempsky): Integrate into DevirtualizeAndInlineFunc below.
ir.VisitFuncsBottomUp(typecheck.Target.Funcs, func(list []*ir.Func, recursive bool) {
inlheur.SetupScoreAdjustments()
}
- var inlProfile *pgo.Profile // copy of profile for inlining
+ var inlProfile *pgoir.Profile // copy of profile for inlining
if base.Debug.PGOInline != 0 {
inlProfile = profile
}
// DevirtualizeAndInlineFunc interleaves devirtualization and inlining
// on a single function.
-func DevirtualizeAndInlineFunc(fn *ir.Func, profile *pgo.Profile) {
+func DevirtualizeAndInlineFunc(fn *ir.Func, profile *pgoir.Profile) {
ir.WithFunc(fn, func() {
if base.Flag.LowerL != 0 {
if inlheur.Enabled() && !fn.Wrapper() {