@@ -788,8 +788,7 @@ static bool buildModuleFromInterface(const CompilerInvocation &Invocation,
788
788
}
789
789
790
790
static bool compileLLVMIR (const CompilerInvocation &Invocation,
791
- CompilerInstance &Instance,
792
- UnifiedStatsReporter *Stats) {
791
+ CompilerInstance &Instance) {
793
792
auto &LLVMContext = getGlobalLLVMContext ();
794
793
795
794
// Load in bitcode file.
@@ -826,8 +825,7 @@ static bool compileLLVMIR(const CompilerInvocation &Invocation,
826
825
return performLLVM (Invocation.getIRGenOptions (),
827
826
Instance.getASTContext (), Module.get (),
828
827
Invocation.getFrontendOptions ()
829
- .InputsAndOutputs .getSingleOutputFilename (),
830
- Stats);
828
+ .InputsAndOutputs .getSingleOutputFilename ());
831
829
}
832
830
833
831
static void verifyGenericSignaturesIfNeeded (const CompilerInvocation &Invocation,
@@ -1085,23 +1083,21 @@ static bool performCompileStepsPostSILGen(
1085
1083
CompilerInstance &Instance, const CompilerInvocation &Invocation,
1086
1084
std::unique_ptr<SILModule> SM, bool astGuaranteedToCorrespondToSIL,
1087
1085
ModuleOrSourceFile MSF, const PrimarySpecificPaths &PSPs,
1088
- bool moduleIsPublic, int &ReturnValue, FrontendObserver *observer,
1089
- UnifiedStatsReporter *Stats);
1086
+ bool moduleIsPublic, int &ReturnValue, FrontendObserver *observer);
1090
1087
1091
1088
static bool
1092
1089
performCompileStepsPostSema (const CompilerInvocation &Invocation,
1093
1090
CompilerInstance &Instance,
1094
1091
bool moduleIsPublic, int &ReturnValue,
1095
- FrontendObserver *observer,
1096
- UnifiedStatsReporter *Stats) {
1092
+ FrontendObserver *observer) {
1097
1093
auto mod = Instance.getMainModule ();
1098
1094
if (auto SM = Instance.takeSILModule ()) {
1099
1095
const PrimarySpecificPaths PSPs =
1100
1096
Instance.getPrimarySpecificPathsForAtMostOnePrimary ();
1101
1097
return performCompileStepsPostSILGen (Instance, Invocation, std::move (SM),
1102
1098
/* ASTGuaranteedToCorrespondToSIL=*/ false ,
1103
1099
mod, PSPs, moduleIsPublic,
1104
- ReturnValue, observer, Stats );
1100
+ ReturnValue, observer);
1105
1101
}
1106
1102
1107
1103
const SILOptions &SILOpts = Invocation.getSILOptions ();
@@ -1122,7 +1118,7 @@ performCompileStepsPostSema(const CompilerInvocation &Invocation,
1122
1118
return performCompileStepsPostSILGen (Instance, Invocation, std::move (SM),
1123
1119
astGuaranteedToCorrespondToSIL,
1124
1120
mod, PSPs, moduleIsPublic,
1125
- ReturnValue, observer, Stats );
1121
+ ReturnValue, observer);
1126
1122
}
1127
1123
// If there are primary source files, build a separate SILModule for
1128
1124
// each source file, and run the remaining SILOpt-Serialize-IRGen-LLVM
@@ -1136,7 +1132,7 @@ performCompileStepsPostSema(const CompilerInvocation &Invocation,
1136
1132
result |= performCompileStepsPostSILGen (Instance, Invocation, std::move (SM),
1137
1133
/* ASTGuaranteedToCorrespondToSIL*/ true ,
1138
1134
PrimaryFile, PSPs, moduleIsPublic,
1139
- ReturnValue, observer, Stats );
1135
+ ReturnValue, observer);
1140
1136
}
1141
1137
1142
1138
return result;
@@ -1155,7 +1151,7 @@ performCompileStepsPostSema(const CompilerInvocation &Invocation,
1155
1151
result |= performCompileStepsPostSILGen (Instance, Invocation, std::move (SM),
1156
1152
!fileIsSIB (SASTF),
1157
1153
mod, PSPs, moduleIsPublic,
1158
- ReturnValue, observer, Stats );
1154
+ ReturnValue, observer);
1159
1155
}
1160
1156
}
1161
1157
@@ -1233,8 +1229,7 @@ static bool performCompile(CompilerInstance &Instance,
1233
1229
const CompilerInvocation &Invocation,
1234
1230
ArrayRef<const char *> Args,
1235
1231
int &ReturnValue,
1236
- FrontendObserver *observer,
1237
- UnifiedStatsReporter *Stats) {
1232
+ FrontendObserver *observer) {
1238
1233
FrontendOptions opts = Invocation.getFrontendOptions ();
1239
1234
FrontendOptions::ActionType Action = opts.RequestedAction ;
1240
1235
@@ -1256,7 +1251,7 @@ static bool performCompile(CompilerInstance &Instance,
1256
1251
return buildModuleFromInterface (Invocation, Instance);
1257
1252
1258
1253
if (Invocation.getInputKind () == InputFileKind::LLVM)
1259
- return compileLLVMIR (Invocation, Instance, Stats );
1254
+ return compileLLVMIR (Invocation, Instance);
1260
1255
1261
1256
if (FrontendOptions::shouldActionOnlyParse (Action)) {
1262
1257
// Disable delayed parsing of type and function bodies when we've been
@@ -1284,8 +1279,9 @@ static bool performCompile(CompilerInstance &Instance,
1284
1279
if (observer)
1285
1280
observer->performedSemanticAnalysis (Instance);
1286
1281
1287
- if (Stats)
1282
+ if (auto * Stats = Context. Stats ) {
1288
1283
countStatsPostSema (*Stats, Instance);
1284
+ }
1289
1285
1290
1286
{
1291
1287
FrontendOptions::DebugCrashMode CrashMode = opts.CrashMode ;
@@ -1358,7 +1354,7 @@ static bool performCompile(CompilerInstance &Instance,
1358
1354
" All actions not requiring SILGen must have been handled!" );
1359
1355
1360
1356
return performCompileStepsPostSema (Invocation, Instance, moduleIsPublic,
1361
- ReturnValue, observer, Stats );
1357
+ ReturnValue, observer);
1362
1358
}
1363
1359
1364
1360
static bool serializeSIB (SILModule *SM, const PrimarySpecificPaths &PSPs,
@@ -1467,8 +1463,7 @@ static bool validateTBDIfNeeded(const CompilerInvocation &Invocation,
1467
1463
static bool generateCode (const CompilerInvocation &Invocation,
1468
1464
CompilerInstance &Instance, StringRef OutputFilename,
1469
1465
llvm::Module *IRModule,
1470
- llvm::GlobalVariable *HashGlobal,
1471
- UnifiedStatsReporter *Stats) {
1466
+ llvm::GlobalVariable *HashGlobal) {
1472
1467
std::unique_ptr<llvm::TargetMachine> TargetMachine = createTargetMachine (
1473
1468
Invocation.getIRGenOptions (), Instance.getASTContext ());
1474
1469
version::Version EffectiveLanguageVersion =
@@ -1489,9 +1484,10 @@ static bool generateCode(const CompilerInvocation &Invocation,
1489
1484
}
1490
1485
1491
1486
// Now that we have a single IR Module, hand it over to performLLVM.
1492
- return performLLVM (Invocation.getIRGenOptions (), & Instance.getDiags (),
1487
+ return performLLVM (Invocation.getIRGenOptions (), Instance.getDiags (),
1493
1488
nullptr , HashGlobal, IRModule, TargetMachine.get (),
1494
- EffectiveLanguageVersion, OutputFilename, Stats);
1489
+ EffectiveLanguageVersion, OutputFilename,
1490
+ Instance.getStatsReporter ());
1495
1491
}
1496
1492
1497
1493
static void collectLinkerDirectives (const CompilerInvocation &Invocation,
@@ -1509,8 +1505,7 @@ static bool performCompileStepsPostSILGen(
1509
1505
CompilerInstance &Instance, const CompilerInvocation &Invocation,
1510
1506
std::unique_ptr<SILModule> SM, bool astGuaranteedToCorrespondToSIL,
1511
1507
ModuleOrSourceFile MSF, const PrimarySpecificPaths &PSPs,
1512
- bool moduleIsPublic, int &ReturnValue, FrontendObserver *observer,
1513
- UnifiedStatsReporter *Stats) {
1508
+ bool moduleIsPublic, int &ReturnValue, FrontendObserver *observer) {
1514
1509
1515
1510
FrontendOptions opts = Invocation.getFrontendOptions ();
1516
1511
FrontendOptions::ActionType Action = opts.RequestedAction ;
@@ -1525,6 +1520,7 @@ static bool performCompileStepsPostSILGen(
1525
1520
if (observer)
1526
1521
observer->performedSILGeneration (*SM);
1527
1522
1523
+ auto *Stats = Instance.getASTContext ().Stats ;
1528
1524
if (Stats)
1529
1525
countStatsPostSILGen (*Stats, *SM);
1530
1526
@@ -1568,7 +1564,7 @@ static bool performCompileStepsPostSILGen(
1568
1564
SM->setSerializeSILAction (SerializeSILModuleAction);
1569
1565
1570
1566
// Perform optimizations and mandatory/diagnostic passes.
1571
- if (Instance.performSILProcessing (SM.get (), Stats ))
1567
+ if (Instance.performSILProcessing (SM.get ()))
1572
1568
return true ;
1573
1569
1574
1570
if (observer)
@@ -1662,7 +1658,7 @@ static bool performCompileStepsPostSILGen(
1662
1658
return true ;
1663
1659
1664
1660
return generateCode (Invocation, Instance, OutputFilename, IRModule.get (),
1665
- HashGlobal, Stats ) ||
1661
+ HashGlobal) ||
1666
1662
HadError;
1667
1663
}
1668
1664
@@ -2146,8 +2142,7 @@ int swift::performFrontend(ArrayRef<const char *> Args,
2146
2142
2147
2143
int ReturnValue = 0 ;
2148
2144
bool HadError =
2149
- performCompile (*Instance, Invocation, Args, ReturnValue, observer,
2150
- StatsReporter.get ());
2145
+ performCompile (*Instance, Invocation, Args, ReturnValue, observer);
2151
2146
2152
2147
if (!HadError) {
2153
2148
Mangle::printManglingStats ();
@@ -2175,7 +2170,7 @@ int swift::performFrontend(ArrayRef<const char *> Args,
2175
2170
}
2176
2171
2177
2172
auto r = finishDiagProcessing (HadError ? 1 : ReturnValue);
2178
- if (StatsReporter)
2173
+ if (auto * StatsReporter = Instance-> getStatsReporter () )
2179
2174
StatsReporter->noteCurrentProcessExitStatus (r);
2180
2175
return r;
2181
2176
}
0 commit comments