@@ -782,17 +782,46 @@ class PerformanceDiagnosticsPass : public SILModuleTransform {
782
782
}
783
783
784
784
if (getModule ()->getOptions ().EmbeddedSwift ) {
785
+ // Run embedded Swift SIL checks for metatype/existential use, and
786
+ // allocation use (under -no-allocations mode). Try to start with public
787
+ // and exported functions to get better call tree information.
788
+ SmallVector<SILFunction *, 8 > externallyVisibleFunctions;
789
+ SmallVector<SILFunction *, 8 > vtableMembers;
790
+ SmallVector<SILFunction *, 8 > others;
791
+ SmallVector<SILFunction *, 8 > constructorsAndDestructors;
792
+
785
793
for (SILFunction &function : *module ) {
786
- // Don't check constructors and destructors directly, they will be
787
- // checked if called from other functions, with better source loc info.
788
794
auto func = function.getLocation ().getAsASTNode <AbstractFunctionDecl>();
789
795
if (func) {
790
796
if (isa<DestructorDecl>(func) || isa<ConstructorDecl>(func)) {
797
+ constructorsAndDestructors.push_back (&function);
798
+ continue ;
799
+ }
800
+ if (getMethodDispatch (func) == MethodDispatch::Class) {
801
+ vtableMembers.push_back (&function);
791
802
continue ;
792
803
}
793
804
}
794
805
795
- diagnoser.visitFunctionEmbeddedSwift (&function);
806
+ if (function.isPossiblyUsedExternally ()) {
807
+ externallyVisibleFunctions.push_back (&function);
808
+ continue ;
809
+ }
810
+
811
+ others.push_back (&function);
812
+ }
813
+
814
+ for (SILFunction *function : externallyVisibleFunctions) {
815
+ diagnoser.visitFunctionEmbeddedSwift (function);
816
+ }
817
+ for (SILFunction *function : vtableMembers) {
818
+ diagnoser.visitFunctionEmbeddedSwift (function);
819
+ }
820
+ for (SILFunction *function : others) {
821
+ diagnoser.visitFunctionEmbeddedSwift (function);
822
+ }
823
+ for (SILFunction *function : constructorsAndDestructors) {
824
+ diagnoser.visitFunctionEmbeddedSwift (function);
796
825
}
797
826
}
798
827
}
0 commit comments