15
15
#include " swift/AST/SemanticAttrs.h"
16
16
#include " swift/SIL/BasicBlockDatastructures.h"
17
17
#include " swift/SIL/InstructionUtils.h"
18
+ #include " swift/SIL/PrettyStackTrace.h"
18
19
#include " swift/SIL/ApplySite.h"
19
20
#include " swift/SILOptimizer/Analysis/ArraySemantic.h"
20
21
#include " swift/SILOptimizer/Analysis/BasicCalleeAnalysis.h"
@@ -119,6 +120,9 @@ static bool isEffectFreeArraySemanticCall(SILInstruction *inst) {
119
120
bool PerformanceDiagnostics::visitFunction (SILFunction *function,
120
121
PerformanceConstraints perfConstr,
121
122
LocWithParent *parentLoc) {
123
+ PrettyStackTraceSILFunction stackTrace (
124
+ " Running performance diangostics on (visiting) " , function);
125
+
122
126
if (!function->isDefinition ())
123
127
return false ;
124
128
@@ -156,6 +160,8 @@ bool PerformanceDiagnostics::visitFunction(SILFunction *function,
156
160
if (visitCallee (&inst, bca->getCalleeList (as), perfConstr, parentLoc))
157
161
return true ;
158
162
} else if (auto *bi = dyn_cast<BuiltinInst>(&inst)) {
163
+ PrettyStackTraceSILNode biStackTrace (
164
+ " Validating built in (once, once with context)" , bi);
159
165
switch (bi->getBuiltinInfo ().ID ) {
160
166
case BuiltinValueKind::Once:
161
167
case BuiltinValueKind::OnceWithContext:
@@ -204,6 +210,8 @@ bool PerformanceDiagnostics::checkClosureValue(SILValue closure,
204
210
SILInstruction *callInst,
205
211
PerformanceConstraints perfConstr,
206
212
LocWithParent *parentLoc) {
213
+ PrettyStackTraceSILNode closureStackTrace (" Validating closure" , closure);
214
+
207
215
// Walk through the definition of the closure until we find the "underlying"
208
216
// function_ref instruction.
209
217
while (!isa<FunctionRefInst>(closure)) {
@@ -243,6 +251,8 @@ bool PerformanceDiagnostics::visitCallee(SILInstruction *callInst,
243
251
CalleeList callees,
244
252
PerformanceConstraints perfConstr,
245
253
LocWithParent *parentLoc) {
254
+ PrettyStackTraceSILNode callStackTrace (" Validating callee" , callInst);
255
+
246
256
LocWithParent asLoc (callInst->getLoc ().getSourceLoc (), parentLoc);
247
257
LocWithParent *loc = &asLoc;
248
258
if (parentLoc && asLoc.loc == callInst->getFunction ()->getLocation ().getSourceLoc ())
@@ -281,6 +291,8 @@ bool PerformanceDiagnostics::visitCallee(SILInstruction *callInst,
281
291
}
282
292
283
293
static bool metatypeUsesAreNotRelevant (MetatypeInst *mt) {
294
+ PrettyStackTraceSILNode mtStackTrace (" Validating metatype" , mt);
295
+
284
296
for (Operand *use : mt->getUses ()) {
285
297
if (auto *bi = dyn_cast<BuiltinInst>(use->getUser ())) {
286
298
switch (bi->getBuiltinInfo ().ID ) {
@@ -303,6 +315,8 @@ static bool metatypeUsesAreNotRelevant(MetatypeInst *mt) {
303
315
bool PerformanceDiagnostics::visitInst (SILInstruction *inst,
304
316
PerformanceConstraints perfConstr,
305
317
LocWithParent *parentLoc) {
318
+ PrettyStackTraceSILNode stackTrace (" validating sil instruction (visiting)" , inst);
319
+
306
320
SILType impactType;
307
321
RuntimeEffect impact = getRuntimeEffect (inst, impactType);
308
322
LocWithParent loc (inst->getLoc ().getSourceLoc (), parentLoc);
0 commit comments