@@ -36,10 +36,11 @@ import (
36
36
"cmd/compile/internal/inline/inlheur"
37
37
"cmd/compile/internal/ir"
38
38
"cmd/compile/internal/logopt"
39
- "cmd/compile/internal/pgo"
39
+ pgoir "cmd/compile/internal/pgo"
40
40
"cmd/compile/internal/typecheck"
41
41
"cmd/compile/internal/types"
42
42
"cmd/internal/obj"
43
+ "cmd/internal/pgo"
43
44
)
44
45
45
46
// Inlining budget parameters, gathered in one place
@@ -58,11 +59,11 @@ const (
58
59
var (
59
60
// List of all hot callee nodes.
60
61
// TODO(prattmic): Make this non-global.
61
- candHotCalleeMap = make (map [* pgo .IRNode ]struct {})
62
+ candHotCalleeMap = make (map [* pgoir .IRNode ]struct {})
62
63
63
64
// List of all hot call sites. CallSiteInfo.Callee is always nil.
64
65
// TODO(prattmic): Make this non-global.
65
- candHotEdgeMap = make (map [pgo .CallSiteInfo ]struct {})
66
+ candHotEdgeMap = make (map [pgoir .CallSiteInfo ]struct {})
66
67
67
68
// Threshold in percentage for hot callsite inlining.
68
69
inlineHotCallSiteThresholdPercent float64
78
79
)
79
80
80
81
// PGOInlinePrologue records the hot callsites from ir-graph.
81
- func PGOInlinePrologue (p * pgo .Profile ) {
82
+ func PGOInlinePrologue (p * pgoir .Profile ) {
82
83
if base .Debug .PGOInlineCDFThreshold != "" {
83
84
if s , err := strconv .ParseFloat (base .Debug .PGOInlineCDFThreshold , 64 ); err == nil && s >= 0 && s <= 100 {
84
85
inlineCDFHotCallSiteThresholdPercent = s
@@ -103,7 +104,7 @@ func PGOInlinePrologue(p *pgo.Profile) {
103
104
}
104
105
// mark hot call sites
105
106
if caller := p .WeightedCG .IRNodes [n .CallerName ]; caller != nil && caller .AST != nil {
106
- csi := pgo .CallSiteInfo {LineOffset : n .CallSiteOffset , Caller : caller .AST }
107
+ csi := pgoir .CallSiteInfo {LineOffset : n .CallSiteOffset , Caller : caller .AST }
107
108
candHotEdgeMap [csi ] = struct {}{}
108
109
}
109
110
}
@@ -120,7 +121,7 @@ func PGOInlinePrologue(p *pgo.Profile) {
120
121
// (currently only used in debug prints) (in case of equal weights,
121
122
// comparing with the threshold may not accurately reflect which nodes are
122
123
// considered hot).
123
- func hotNodesFromCDF (p * pgo .Profile ) (float64 , []pgo.NamedCallEdge ) {
124
+ func hotNodesFromCDF (p * pgoir .Profile ) (float64 , []pgo.NamedCallEdge ) {
124
125
cum := int64 (0 )
125
126
for i , n := range p .NamedEdgeMap .ByWeight {
126
127
w := p .NamedEdgeMap .Weight [n ]
@@ -136,7 +137,7 @@ func hotNodesFromCDF(p *pgo.Profile) (float64, []pgo.NamedCallEdge) {
136
137
}
137
138
138
139
// CanInlineFuncs computes whether a batch of functions are inlinable.
139
- func CanInlineFuncs (funcs []* ir.Func , profile * pgo .Profile ) {
140
+ func CanInlineFuncs (funcs []* ir.Func , profile * pgoir .Profile ) {
140
141
if profile != nil {
141
142
PGOInlinePrologue (profile )
142
143
}
@@ -224,7 +225,7 @@ func GarbageCollectUnreferencedHiddenClosures() {
224
225
// possibility that a call to the function might have its score
225
226
// adjusted downwards. If 'verbose' is set, then print a remark where
226
227
// we boost the budget due to PGO.
227
- func inlineBudget (fn * ir.Func , profile * pgo .Profile , relaxed bool , verbose bool ) int32 {
228
+ func inlineBudget (fn * ir.Func , profile * pgoir .Profile , relaxed bool , verbose bool ) int32 {
228
229
// Update the budget for profile-guided inlining.
229
230
budget := int32 (inlineMaxBudget )
230
231
if profile != nil {
@@ -246,7 +247,7 @@ func inlineBudget(fn *ir.Func, profile *pgo.Profile, relaxed bool, verbose bool)
246
247
// CanInline determines whether fn is inlineable.
247
248
// If so, CanInline saves copies of fn.Body and fn.Dcl in fn.Inl.
248
249
// fn and fn.Body will already have been typechecked.
249
- func CanInline (fn * ir.Func , profile * pgo .Profile ) {
250
+ func CanInline (fn * ir.Func , profile * pgoir .Profile ) {
250
251
if fn .Nname == nil {
251
252
base .Fatalf ("CanInline no nname %+v" , fn )
252
253
}
@@ -451,7 +452,7 @@ type hairyVisitor struct {
451
452
extraCallCost int32
452
453
usedLocals ir.NameSet
453
454
do func (ir.Node ) bool
454
- profile * pgo .Profile
455
+ profile * pgoir .Profile
455
456
}
456
457
457
458
func (v * hairyVisitor ) tooHairy (fn * ir.Func ) bool {
@@ -768,7 +769,7 @@ func IsBigFunc(fn *ir.Func) bool {
768
769
769
770
// TryInlineCall returns an inlined call expression for call, or nil
770
771
// if inlining is not possible.
771
- func TryInlineCall (callerfn * ir.Func , call * ir.CallExpr , bigCaller bool , profile * pgo .Profile ) * ir.InlinedCallExpr {
772
+ func TryInlineCall (callerfn * ir.Func , call * ir.CallExpr , bigCaller bool , profile * pgoir .Profile ) * ir.InlinedCallExpr {
772
773
if base .Flag .LowerL == 0 {
773
774
return nil
774
775
}
@@ -804,7 +805,7 @@ func TryInlineCall(callerfn *ir.Func, call *ir.CallExpr, bigCaller bool, profile
804
805
805
806
// inlCallee takes a function-typed expression and returns the underlying function ONAME
806
807
// that it refers to if statically known. Otherwise, it returns nil.
807
- func inlCallee (caller * ir.Func , fn ir.Node , profile * pgo .Profile ) (res * ir.Func ) {
808
+ func inlCallee (caller * ir.Func , fn ir.Node , profile * pgoir .Profile ) (res * ir.Func ) {
808
809
fn = ir .StaticValue (fn )
809
810
switch fn .Op () {
810
811
case ir .OMETHEXPR :
@@ -877,8 +878,8 @@ func inlineCostOK(n *ir.CallExpr, caller, callee *ir.Func, bigCaller bool) (bool
877
878
// We'll also allow inlining of hot functions below inlineHotMaxBudget,
878
879
// but only in small functions.
879
880
880
- lineOffset := pgo .NodeLineOffset (n , caller )
881
- csi := pgo .CallSiteInfo {LineOffset : lineOffset , Caller : caller }
881
+ lineOffset := pgoir .NodeLineOffset (n , caller )
882
+ csi := pgoir .CallSiteInfo {LineOffset : lineOffset , Caller : caller }
882
883
if _ , ok := candHotEdgeMap [csi ]; ! ok {
883
884
// Cold
884
885
return false , maxCost , metric
@@ -1188,17 +1189,17 @@ func isAtomicCoverageCounterUpdate(cn *ir.CallExpr) bool {
1188
1189
return v
1189
1190
}
1190
1191
1191
- func PostProcessCallSites (profile * pgo .Profile ) {
1192
+ func PostProcessCallSites (profile * pgoir .Profile ) {
1192
1193
if base .Debug .DumpInlCallSiteScores != 0 {
1193
- budgetCallback := func (fn * ir.Func , prof * pgo .Profile ) (int32 , bool ) {
1194
+ budgetCallback := func (fn * ir.Func , prof * pgoir .Profile ) (int32 , bool ) {
1194
1195
v := inlineBudget (fn , prof , false , false )
1195
1196
return v , v == inlineHotMaxBudget
1196
1197
}
1197
1198
inlheur .DumpInlCallSiteScores (profile , budgetCallback )
1198
1199
}
1199
1200
}
1200
1201
1201
- func analyzeFuncProps (fn * ir.Func , p * pgo .Profile ) {
1202
+ func analyzeFuncProps (fn * ir.Func , p * pgoir .Profile ) {
1202
1203
canInline := func (fn * ir.Func ) { CanInline (fn , p ) }
1203
1204
budgetForFunc := func (fn * ir.Func ) int32 {
1204
1205
return inlineBudget (fn , p , true , false )
0 commit comments