@@ -185,14 +185,18 @@ func shouldPGODevirt(fn *ir.Func) bool {
185
185
}()
186
186
}
187
187
188
- reason = inline .InlineImpossible (fn )
189
- if reason == "no function body" {
190
- // TODO: temp fix. InlineImpossible is confused and/or we seemingly can ignore this complaint.
191
- // If we've reached here, we've already confirmed we have a Dst.AST, which implies
192
- // the destination is visible from this package.
193
- reason = ""
194
- return true
188
+ if isImportedFunc (fn ) {
189
+ if typecheck .HaveInlineBody (fn ) {
190
+ // The inliner has already determined this is inlinable.
191
+ return true
192
+ } else {
193
+ reason = "imported function that is not inlinable"
194
+ return false
195
+ }
195
196
}
197
+
198
+ // Local function.
199
+ reason = inline .InlineImpossible (fn )
196
200
if reason != "" {
197
201
return false
198
202
}
@@ -364,11 +368,11 @@ func rewriteCondCall(call *ir.CallExpr, curfn, callee *ir.Func, concretetyp *typ
364
368
elseBlock .Append (call )
365
369
} else {
366
370
// Copy slice so edits in one location don't affect another.
367
- thenRet := append ([]ir.Node (nil ), retvars ... )
371
+ thenRet := append ([]ir.Node (nil ), retvars ... )
368
372
thenAsList := ir .NewAssignListStmt (pos , ir .OAS2 , thenRet , []ir.Node {concreteCall })
369
373
thenBlock .Append (typecheck .Stmt (thenAsList ))
370
374
371
- elseRet := append ([]ir.Node (nil ), retvars ... )
375
+ elseRet := append ([]ir.Node (nil ), retvars ... )
372
376
elseAsList := ir .NewAssignListStmt (pos , ir .OAS2 , elseRet , []ir.Node {call })
373
377
elseBlock .Append (typecheck .Stmt (elseAsList ))
374
378
}
@@ -537,3 +541,8 @@ func findHotConcreteCallee(p *pgo.Profile, caller *ir.Func, call *ir.CallExpr) (
537
541
}
538
542
return hottest .Dst .AST , hottest .Weight
539
543
}
544
+
545
+ func isImportedFunc (fn * ir.Func ) bool {
546
+ // TODO: what is proper way to check this? does it exist already?
547
+ return fn .Sym ().Pkg .Path != base .Ctxt .Pkgpath
548
+ }
0 commit comments