@@ -64,8 +64,8 @@ class PerformanceDiagnostics {
6464 bool visitInst (SILInstruction *inst, PerformanceConstraints perfConstr,
6565 LocWithParent *parentLoc);
6666
67- bool visitCallee (FullApplySite as, PerformanceConstraints perfConstr ,
68- LocWithParent *parentLoc);
67+ bool visitCallee (SILInstruction *callInst, CalleeList callees ,
68+ PerformanceConstraints perfConstr, LocWithParent *parentLoc);
6969
7070 template <typename ...ArgTypes>
7171 void diagnose (LocWithParent loc, Diag<ArgTypes...> ID,
@@ -108,21 +108,37 @@ bool PerformanceDiagnostics::visitFunction(SILFunction *function,
108108 continue ;
109109
110110 // Recursively walk into the callees.
111- if (visitCallee (as, perfConstr, parentLoc))
111+ if (visitCallee (&inst, bca-> getCalleeList (as), perfConstr, parentLoc))
112112 return true ;
113+ } else if (auto *bi = dyn_cast<BuiltinInst>(&inst)) {
114+ switch (bi->getBuiltinInfo ().ID ) {
115+ case BuiltinValueKind::Once:
116+ case BuiltinValueKind::OnceWithContext:
117+ if (auto *fri = dyn_cast<FunctionRefInst>(bi->getArguments ()[1 ])) {
118+ if (visitCallee (bi, fri->getReferencedFunction (), perfConstr, parentLoc))
119+ return true ;
120+ } else {
121+ LocWithParent loc (inst.getLoc ().getSourceLoc (), parentLoc);
122+ diagnose (loc, diag::performance_unknown_callees);
123+ return true ;
124+ }
125+ break ;
126+ default :
127+ break ;
128+ }
113129 }
114130 }
115131 }
116132 return false ;
117133}
118134
119- bool PerformanceDiagnostics::visitCallee (FullApplySite as ,
120- PerformanceConstraints perfConstr ,
121- LocWithParent *parentLoc) {
122- CalleeList callees = bca-> getCalleeList (as);
123- LocWithParent asLoc (as. getLoc ().getSourceLoc (), parentLoc);
135+ bool PerformanceDiagnostics::visitCallee (SILInstruction *callInst ,
136+ CalleeList callees ,
137+ PerformanceConstraints perfConstr,
138+ LocWithParent *parentLoc) {
139+ LocWithParent asLoc (callInst-> getLoc ().getSourceLoc (), parentLoc);
124140 LocWithParent *loc = &asLoc;
125- if (parentLoc && asLoc.loc == as. getFunction ()->getLocation ().getSourceLoc ())
141+ if (parentLoc && asLoc.loc == callInst-> getFunction ()->getLocation ().getSourceLoc ())
126142 loc = parentLoc;
127143
128144 if (callees.isIncomplete ()) {
0 commit comments