@@ -353,7 +353,26 @@ bool PerformanceDiagnostics::visitInst(SILInstruction *inst,
353
353
SILType impactType;
354
354
RuntimeEffect impact = getRuntimeEffect (inst, impactType);
355
355
LocWithParent loc (inst->getLoc ().getSourceLoc (), parentLoc);
356
-
356
+
357
+ if (isa<WitnessMethodInst>(inst) ||
358
+ isa<InitExistentialAddrInst>(inst) ||
359
+ isa<InitExistentialValueInst>(inst) ||
360
+ isa<InitExistentialRefInst>(inst) ||
361
+ isa<OpenExistentialValueInst>(inst) ||
362
+ isa<OpenExistentialRefInst>(inst) ||
363
+ isa<OpenExistentialAddrInst>(inst) ||
364
+ isa<OpenExistentialBoxInst>(inst) ||
365
+ isa<OpenExistentialBoxValueInst>(inst) ||
366
+ isa<InitExistentialMetatypeInst>(inst) ||
367
+ isa<OpenExistentialMetatypeInst>(inst)) {
368
+ PrettyStackTracePerformanceDiagnostics stackTrace (" existential" , inst);
369
+ diagnose (loc, diag::performance_metadata, " existential" );
370
+ return true ;
371
+ }
372
+
373
+ if (perfConstr == PerformanceConstraints::None)
374
+ return false ;
375
+
357
376
if (impact & RuntimeEffect::Casting) {
358
377
// TODO: be more specific on casting.
359
378
// E.g. distinguish locking and allocating dynamic casts, etc.
@@ -497,6 +516,11 @@ bool PerformanceDiagnostics::visitInst(SILInstruction *inst,
497
516
void PerformanceDiagnostics::checkNonAnnotatedFunction (SILFunction *function) {
498
517
for (SILBasicBlock &block : *function) {
499
518
for (SILInstruction &inst : block) {
519
+ if (function->getASTContext ().LangOpts .hasFeature (Feature::Embedded)) {
520
+ auto loc = LocWithParent (inst.getLoc ().getSourceLoc (), nullptr );
521
+ visitInst (&inst, PerformanceConstraints::None, &loc);
522
+ }
523
+
500
524
auto as = FullApplySite::isa (&inst);
501
525
if (!as)
502
526
continue ;
@@ -592,14 +616,20 @@ class PerformanceDiagnosticsPass : public SILModuleTransform {
592
616
}
593
617
}
594
618
595
- if (!annotatedFunctionsFound)
619
+ if (!annotatedFunctionsFound &&
620
+ !getModule ()->getASTContext ().LangOpts .hasFeature (Feature::Embedded))
596
621
return ;
597
622
598
623
for (SILFunction &function : *module) {
599
624
// Don't rerun diagnostics on deserialized functions.
600
625
if (function.wasDeserializedCanonical ())
601
626
continue ;
602
627
628
+ // Don't check generic functions, they're about to be removed anyway.
629
+ if (getModule ()->getASTContext ().LangOpts .hasFeature (Feature::Embedded) &&
630
+ function.getLoweredFunctionType ()->getSubstGenericSignature ())
631
+ continue ;
632
+
603
633
if (function.getPerfConstraints () == PerformanceConstraints::None) {
604
634
diagnoser.checkNonAnnotatedFunction (&function);
605
635
}
0 commit comments