@@ -64,8 +64,8 @@ class PerformanceDiagnostics {
64
64
bool visitInst (SILInstruction *inst, PerformanceConstraints perfConstr,
65
65
LocWithParent *parentLoc);
66
66
67
- bool visitCallee (FullApplySite as, PerformanceConstraints perfConstr ,
68
- LocWithParent *parentLoc);
67
+ bool visitCallee (SILInstruction *callInst, CalleeList callees ,
68
+ PerformanceConstraints perfConstr, LocWithParent *parentLoc);
69
69
70
70
template <typename ...ArgTypes>
71
71
void diagnose (LocWithParent loc, Diag<ArgTypes...> ID,
@@ -108,21 +108,37 @@ bool PerformanceDiagnostics::visitFunction(SILFunction *function,
108
108
continue ;
109
109
110
110
// Recursively walk into the callees.
111
- if (visitCallee (as, perfConstr, parentLoc))
111
+ if (visitCallee (&inst, bca-> getCalleeList (as), perfConstr, parentLoc))
112
112
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
+ }
113
129
}
114
130
}
115
131
}
116
132
return false ;
117
133
}
118
134
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);
124
140
LocWithParent *loc = &asLoc;
125
- if (parentLoc && asLoc.loc == as. getFunction ()->getLocation ().getSourceLoc ())
141
+ if (parentLoc && asLoc.loc == callInst-> getFunction ()->getLocation ().getSourceLoc ())
126
142
loc = parentLoc;
127
143
128
144
if (callees.isIncomplete ()) {
0 commit comments