@@ -469,10 +469,16 @@ void addFunctionPasses(SILPassPipelinePlan &P,
469
469
// makes a change we'll end up restarting the function passes on the
470
470
// current function (after optimizing any new callees).
471
471
P.addDevirtualizer ();
472
- P.addGenericSpecializer ();
473
- // Run devirtualizer after the specializer, because many
474
- // class_method/witness_method instructions may use concrete types now.
475
- P.addDevirtualizer ();
472
+ // MandatoryPerformanceOptimizations already took care of all specializations
473
+ // in embedded Swift mode, running the generic specializer might introduce
474
+ // more generic calls from non-generic functions, which breaks the assumptions
475
+ // of embedded Swift.
476
+ if (!P.getOptions ().EmbeddedSwift ) {
477
+ P.addGenericSpecializer ();
478
+ // Run devirtualizer after the specializer, because many
479
+ // class_method/witness_method instructions may use concrete types now.
480
+ P.addDevirtualizer ();
481
+ }
476
482
P.addARCSequenceOpts ();
477
483
478
484
if (P.getOptions ().EnableOSSAModules ) {
@@ -754,8 +760,14 @@ static void addMidLevelFunctionPipeline(SILPassPipelinePlan &P) {
754
760
static void addLowLevelPassPipeline (SILPassPipelinePlan &P) {
755
761
P.startPipeline (" LowLevel,Function" , true /* isFunctionPassPipeline*/ );
756
762
757
- // Should be after FunctionSignatureOpts and before the last inliner.
758
- P.addReleaseDevirtualizer ();
763
+ // MandatoryPerformanceOptimizations already took care of all specializations
764
+ // in embedded Swift mode, running the release devirtualizer might introduce
765
+ // more generic calls from non-generic functions, which breaks the assumptions
766
+ // of embedded Swift.
767
+ if (!P.getOptions ().EmbeddedSwift ) {
768
+ // Should be after FunctionSignatureOpts and before the last inliner.
769
+ P.addReleaseDevirtualizer ();
770
+ }
759
771
760
772
addFunctionPasses (P, OptimizationLevelKind::LowLevel);
761
773
@@ -967,13 +979,6 @@ SILPassPipelinePlan::getPerformancePassPipeline(const SILOptions &Options) {
967
979
// Perform optimizations that specialize.
968
980
addClosureSpecializePassPipeline (P);
969
981
970
- // For embedded Swift: We need to re-run VTableSpecializer in case the
971
- // performance inliner and specializer ended up discovering new generic
972
- // classes.
973
- if (Options.EmbeddedSwift ) {
974
- P.addVTableSpecializer ();
975
- }
976
-
977
982
// Run another iteration of the SSA optimizations to optimize the
978
983
// devirtualized inline caches and constants propagated into closures
979
984
// (CapturePropagation).
0 commit comments