@@ -850,27 +850,25 @@ static bool performCompile(CompilerInstance &Instance,
850
850
if (Action == FrontendOptions::ActionType::Parse)
851
851
return Instance.getASTContext ().hadError ();
852
852
853
- if (observer) {
853
+ if (observer)
854
854
observer->performedSemanticAnalysis (Instance);
855
- }
856
855
857
- if (Stats) {
856
+ if (Stats)
858
857
countStatsPostSema (*Stats, Instance);
859
- }
860
858
861
- FrontendOptions::DebugCrashMode CrashMode = opts.CrashMode ;
862
- if (CrashMode == FrontendOptions::DebugCrashMode::AssertAfterParse)
863
- debugFailWithAssertion ();
864
- else if (CrashMode == FrontendOptions::DebugCrashMode::CrashAfterParse)
865
- debugFailWithCrash ();
859
+ {
860
+ FrontendOptions::DebugCrashMode CrashMode = opts.CrashMode ;
861
+ if (CrashMode == FrontendOptions::DebugCrashMode::AssertAfterParse)
862
+ debugFailWithAssertion ();
863
+ else if (CrashMode == FrontendOptions::DebugCrashMode::CrashAfterParse)
864
+ debugFailWithCrash ();
865
+ }
866
866
867
867
ASTContext &Context = Instance.getASTContext ();
868
868
869
869
verifyGenericSignaturesIfNeeded (Invocation, Context);
870
870
871
- if (Invocation.getMigratorOptions ().shouldRunMigrator ()) {
872
- migrator::updateCodeAndEmitRemap (&Instance, Invocation);
873
- }
871
+ (void )migrator::updateCodeAndEmitRemapIfNeeded (&Instance, Invocation);
874
872
875
873
if (Action == FrontendOptions::ActionType::REPL) {
876
874
runREPL (Instance, ProcessCmdLine (Args.begin (), Args.end ()),
@@ -913,6 +911,7 @@ static bool performCompile(CompilerInstance &Instance,
913
911
if (!opts.ObjCHeaderOutputPath .empty ())
914
912
return printAsObjC (opts.ObjCHeaderOutputPath , Instance.getMainModule (),
915
913
opts.ImplicitObjCHeaderPath , moduleIsPublic);
914
+
916
915
return emitIndexDataIfNeeded (Instance.getPrimarySourceFile (), Invocation,
917
916
Instance) ||
918
917
Context.hadError ();
@@ -1037,15 +1036,16 @@ static void setPrivateDiscriminatorIfNeeded(IRGenOptions &IRGenOpts,
1037
1036
IRGenOpts.DWARFDebugFlags += (" -private-discriminator " + PD.str ()).str ();
1038
1037
}
1039
1038
1040
- static bool serializeSIB (FrontendOptions &opts, SILModule *SM,
1041
- ASTContext &Context, ModuleOrSourceFile MSF) {
1039
+ static bool serializeSIBIfNeeded (FrontendOptions &opts, SILModule *SM,
1040
+ ASTContext &Context, ModuleOrSourceFile MSF) {
1042
1041
const std::string &moduleOutputPath = opts.ModuleOutputPath ;
1043
1042
assert (!moduleOutputPath.empty () && " must have an output path" );
1044
1043
1045
1044
SerializationOptions serializationOpts;
1046
1045
serializationOpts.OutputPath = moduleOutputPath.c_str ();
1047
1046
serializationOpts.SerializeAllSIL = true ;
1048
1047
serializationOpts.IsSIB = true ;
1048
+
1049
1049
serialize (MSF, serializationOpts, SM);
1050
1050
return Context.hadError ();
1051
1051
}
@@ -1166,12 +1166,11 @@ static bool performCompileStepsPostSILGen(CompilerInstance &Instance,
1166
1166
SILOptions &SILOpts = Invocation.getSILOptions ();
1167
1167
IRGenOptions &IRGenOpts = Invocation.getIRGenOptions ();
1168
1168
1169
- if (observer) {
1169
+ if (observer)
1170
1170
observer->performedSILGeneration (*SM);
1171
- }
1172
- if (Stats) {
1171
+
1172
+ if (Stats)
1173
1173
countStatsPostSILGen (*Stats, *SM);
1174
- }
1175
1174
1176
1175
// We've been told to emit SIL after SILGen, so write it now.
1177
1176
if (Action == FrontendOptions::ActionType::EmitSILGen) {
@@ -1181,8 +1180,8 @@ static bool performCompileStepsPostSILGen(CompilerInstance &Instance,
1181
1180
1182
1181
if (Action == FrontendOptions::ActionType::EmitSIBGen) {
1183
1182
linkAllIfNeeded (Invocation, SM.get ());
1184
- serializeSIB (Invocation.getFrontendOptions (), SM.get (),
1185
- Instance.getASTContext (), MSF);
1183
+ serializeSIBIfNeeded (Invocation.getFrontendOptions (), SM.get (),
1184
+ Instance.getASTContext (), MSF);
1186
1185
return Context.hadError ();
1187
1186
}
1188
1187
@@ -1222,22 +1221,18 @@ static bool performCompileStepsPostSILGen(CompilerInstance &Instance,
1222
1221
1223
1222
performSILOptimizations (Invocation, SM.get ());
1224
1223
1225
- if (observer) {
1224
+ if (observer)
1226
1225
observer->performedSILOptimization (*SM);
1227
- }
1228
- if (Stats) {
1226
+
1227
+ if (Stats)
1229
1228
countStatsPostSILOpt (*Stats, *SM);
1230
- }
1231
1229
1232
1230
{
1233
1231
SharedTimer timer (" SIL verification, post-optimization" );
1234
1232
SM->verify ();
1235
1233
}
1236
1234
1237
- // Gather instruction counts if we are asked to do so.
1238
- if (SM->getOptions ().PrintInstCounts ) {
1239
- performSILInstCount (&*SM);
1240
- }
1235
+ performSILInstCountIfNeeded (&*SM);
1241
1236
1242
1237
setPrivateDiscriminatorIfNeeded (IRGenOpts, MSF);
1243
1238
@@ -1247,8 +1242,8 @@ static bool performCompileStepsPostSILGen(CompilerInstance &Instance,
1247
1242
}
1248
1243
1249
1244
if (Action == FrontendOptions::ActionType::EmitSIB)
1250
- return serializeSIB (Invocation.getFrontendOptions (), SM.get (),
1251
- Instance.getASTContext (), MSF);
1245
+ return serializeSIBIfNeeded (Invocation.getFrontendOptions (), SM.get (),
1246
+ Instance.getASTContext (), MSF);
1252
1247
1253
1248
const bool haveModulePath =
1254
1249
!opts.ModuleOutputPath .empty () || !opts.ModuleDocOutputPath .empty ();
@@ -1280,7 +1275,6 @@ static bool performCompileStepsPostSILGen(CompilerInstance &Instance,
1280
1275
if (Context.hadError ())
1281
1276
return true ;
1282
1277
1283
- // Convert SIL to a lowered form suitable for IRGen.
1284
1278
runSILLoweringPasses (*SM);
1285
1279
1286
1280
// TODO: remove once the frontend understands what action it should perform
@@ -1307,9 +1301,8 @@ static bool performCompileStepsPostSILGen(CompilerInstance &Instance,
1307
1301
// If the AST Context has no errors but no IRModule is available,
1308
1302
// parallelIRGen happened correctly, since parallel IRGen produces multiple
1309
1303
// modules.
1310
- if (!IRModule) {
1304
+ if (!IRModule)
1311
1305
return HadError;
1312
- }
1313
1306
1314
1307
if (validateTBDIfNeeded (Invocation, MSF, astGuaranteedToCorrespondToSIL,
1315
1308
*IRModule))
0 commit comments