@@ -515,17 +515,6 @@ static void countStatsPostSILGen(UnifiedStatsReporter &Stats,
515
515
C.NumSILGenGlobalVariables += Module.getSILGlobalList ().size ();
516
516
}
517
517
518
- static void countStatsPostSILOpt (UnifiedStatsReporter &Stats,
519
- const SILModule& Module) {
520
- auto &C = Stats.getFrontendCounters ();
521
- // FIXME: calculate these in constant time, via the dense maps.
522
- C.NumSILOptFunctions += Module.getFunctionList ().size ();
523
- C.NumSILOptVtables += Module.getVTableList ().size ();
524
- C.NumSILOptWitnessTables += Module.getWitnessTableList ().size ();
525
- C.NumSILOptDefaultWitnessTables += Module.getDefaultWitnessTableList ().size ();
526
- C.NumSILOptGlobalVariables += Module.getSILGlobalList ().size ();
527
- }
528
-
529
518
static std::unique_ptr<llvm::raw_fd_ostream>
530
519
createOptRecordFile (StringRef Filename, DiagnosticEngine &DE) {
531
520
if (Filename.empty ())
@@ -1038,50 +1027,6 @@ static bool performCompile(CompilerInstance &Instance,
1038
1027
return false ;
1039
1028
}
1040
1029
1041
- // / Perform "stable" optimizations that are invariant across compiler versions.
1042
- static bool performMandatorySILPasses (CompilerInvocation &Invocation,
1043
- SILModule *SM,
1044
- FrontendObserver *observer) {
1045
- if (Invocation.getFrontendOptions ().RequestedAction ==
1046
- FrontendOptions::ActionType::MergeModules) {
1047
- // Don't run diagnostic passes at all.
1048
- } else if (!Invocation.getDiagnosticOptions ().SkipDiagnosticPasses ) {
1049
- if (runSILDiagnosticPasses (*SM))
1050
- return true ;
1051
- } else {
1052
- // Even if we are not supposed to run the diagnostic passes, we still need
1053
- // to run the ownership evaluator.
1054
- if (runSILOwnershipEliminatorPass (*SM))
1055
- return true ;
1056
- }
1057
-
1058
- if (Invocation.getSILOptions ().MergePartialModules )
1059
- SM->linkAllFromCurrentModule ();
1060
- return false ;
1061
- }
1062
-
1063
- // / Perform SIL optimization passes if optimizations haven't been disabled.
1064
- // / These may change across compiler versions.
1065
- static void performSILOptimizations (CompilerInvocation &Invocation,
1066
- SILModule *SM) {
1067
- SharedTimer timer (" SIL optimization" );
1068
- if (Invocation.getFrontendOptions ().RequestedAction ==
1069
- FrontendOptions::ActionType::MergeModules ||
1070
- !Invocation.getSILOptions ().shouldOptimize ()) {
1071
- runSILPassesForOnone (*SM);
1072
- return ;
1073
- }
1074
- runSILOptPreparePasses (*SM);
1075
-
1076
- StringRef CustomPipelinePath =
1077
- Invocation.getSILOptions ().ExternalPassPipelineFilename ;
1078
- if (!CustomPipelinePath.empty ()) {
1079
- runSILOptimizationPassesWithFileSpecification (*SM, CustomPipelinePath);
1080
- } else {
1081
- runSILOptimizationPasses (*SM);
1082
- }
1083
- }
1084
-
1085
1030
// / Get the main source file's private discriminator and attach it to
1086
1031
// / the compile unit's flags.
1087
1032
static void setPrivateDiscriminatorIfNeeded (IRGenOptions &IRGenOpts,
@@ -1255,17 +1200,6 @@ static bool performCompileStepsPostSILGen(
1255
1200
SM->setOptRecordStream (std::move (Output), std::move (OptRecordFile));
1256
1201
}
1257
1202
1258
- if (performMandatorySILPasses (Invocation, SM.get (), observer))
1259
- return true ;
1260
-
1261
- {
1262
- SharedTimer timer (" SIL verification, pre-optimization" );
1263
- SM->verify ();
1264
- }
1265
-
1266
- emitAnyWholeModulePostTypeCheckSupplementaryOutputs (Instance, Invocation,
1267
- moduleIsPublic);
1268
-
1269
1203
// This is the action to be used to serialize SILModule.
1270
1204
// It may be invoked multiple times, but it will perform
1271
1205
// serialization only once. The serialization may either happen
@@ -1286,17 +1220,12 @@ static bool performCompileStepsPostSILGen(
1286
1220
// can be serialized at any moment, e.g. during the optimization pipeline.
1287
1221
SM->setSerializeSILAction (SerializeSILModuleAction);
1288
1222
1289
- performSILOptimizations (Invocation, SM.get ());
1290
-
1291
- if (Stats)
1292
- countStatsPostSILOpt (*Stats, *SM);
1293
-
1294
- {
1295
- SharedTimer timer (" SIL verification, post-optimization" );
1296
- SM->verify ();
1297
- }
1223
+ // Perform optimizations and mandatory/diagnostic passes.
1224
+ if (Instance.performSILProcessing (SM.get (), Stats))
1225
+ return true ;
1298
1226
1299
- performSILInstCountIfNeeded (&*SM);
1227
+ emitAnyWholeModulePostTypeCheckSupplementaryOutputs (Instance, Invocation,
1228
+ moduleIsPublic);
1300
1229
1301
1230
setPrivateDiscriminatorIfNeeded (IRGenOpts, MSF);
1302
1231
0 commit comments