Skip to content

Commit 7dd000b

Browse files
committed
[NFC] Remove the stats reporter parameter from FrontendTool entrypoints
Now that the CompilerInstance owns the stats reporter, use that instead.
1 parent de72824 commit 7dd000b

File tree

1 file changed

+23
-28
lines changed

1 file changed

+23
-28
lines changed

lib/FrontendTool/FrontendTool.cpp

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -788,8 +788,7 @@ static bool buildModuleFromInterface(const CompilerInvocation &Invocation,
788788
}
789789

790790
static bool compileLLVMIR(const CompilerInvocation &Invocation,
791-
CompilerInstance &Instance,
792-
UnifiedStatsReporter *Stats) {
791+
CompilerInstance &Instance) {
793792
auto &LLVMContext = getGlobalLLVMContext();
794793

795794
// Load in bitcode file.
@@ -826,8 +825,7 @@ static bool compileLLVMIR(const CompilerInvocation &Invocation,
826825
return performLLVM(Invocation.getIRGenOptions(),
827826
Instance.getASTContext(), Module.get(),
828827
Invocation.getFrontendOptions()
829-
.InputsAndOutputs.getSingleOutputFilename(),
830-
Stats);
828+
.InputsAndOutputs.getSingleOutputFilename());
831829
}
832830

833831
static void verifyGenericSignaturesIfNeeded(const CompilerInvocation &Invocation,
@@ -1085,23 +1083,21 @@ static bool performCompileStepsPostSILGen(
10851083
CompilerInstance &Instance, const CompilerInvocation &Invocation,
10861084
std::unique_ptr<SILModule> SM, bool astGuaranteedToCorrespondToSIL,
10871085
ModuleOrSourceFile MSF, const PrimarySpecificPaths &PSPs,
1088-
bool moduleIsPublic, int &ReturnValue, FrontendObserver *observer,
1089-
UnifiedStatsReporter *Stats);
1086+
bool moduleIsPublic, int &ReturnValue, FrontendObserver *observer);
10901087

10911088
static bool
10921089
performCompileStepsPostSema(const CompilerInvocation &Invocation,
10931090
CompilerInstance &Instance,
10941091
bool moduleIsPublic, int &ReturnValue,
1095-
FrontendObserver *observer,
1096-
UnifiedStatsReporter *Stats) {
1092+
FrontendObserver *observer) {
10971093
auto mod = Instance.getMainModule();
10981094
if (auto SM = Instance.takeSILModule()) {
10991095
const PrimarySpecificPaths PSPs =
11001096
Instance.getPrimarySpecificPathsForAtMostOnePrimary();
11011097
return performCompileStepsPostSILGen(Instance, Invocation, std::move(SM),
11021098
/*ASTGuaranteedToCorrespondToSIL=*/false,
11031099
mod, PSPs, moduleIsPublic,
1104-
ReturnValue, observer, Stats);
1100+
ReturnValue, observer);
11051101
}
11061102

11071103
const SILOptions &SILOpts = Invocation.getSILOptions();
@@ -1122,7 +1118,7 @@ performCompileStepsPostSema(const CompilerInvocation &Invocation,
11221118
return performCompileStepsPostSILGen(Instance, Invocation, std::move(SM),
11231119
astGuaranteedToCorrespondToSIL,
11241120
mod, PSPs, moduleIsPublic,
1125-
ReturnValue, observer, Stats);
1121+
ReturnValue, observer);
11261122
}
11271123
// If there are primary source files, build a separate SILModule for
11281124
// each source file, and run the remaining SILOpt-Serialize-IRGen-LLVM
@@ -1136,7 +1132,7 @@ performCompileStepsPostSema(const CompilerInvocation &Invocation,
11361132
result |= performCompileStepsPostSILGen(Instance, Invocation, std::move(SM),
11371133
/*ASTGuaranteedToCorrespondToSIL*/true,
11381134
PrimaryFile, PSPs, moduleIsPublic,
1139-
ReturnValue, observer, Stats);
1135+
ReturnValue, observer);
11401136
}
11411137

11421138
return result;
@@ -1155,7 +1151,7 @@ performCompileStepsPostSema(const CompilerInvocation &Invocation,
11551151
result |= performCompileStepsPostSILGen(Instance, Invocation, std::move(SM),
11561152
!fileIsSIB(SASTF),
11571153
mod, PSPs, moduleIsPublic,
1158-
ReturnValue, observer, Stats);
1154+
ReturnValue, observer);
11591155
}
11601156
}
11611157

@@ -1233,8 +1229,7 @@ static bool performCompile(CompilerInstance &Instance,
12331229
const CompilerInvocation &Invocation,
12341230
ArrayRef<const char *> Args,
12351231
int &ReturnValue,
1236-
FrontendObserver *observer,
1237-
UnifiedStatsReporter *Stats) {
1232+
FrontendObserver *observer) {
12381233
FrontendOptions opts = Invocation.getFrontendOptions();
12391234
FrontendOptions::ActionType Action = opts.RequestedAction;
12401235

@@ -1256,7 +1251,7 @@ static bool performCompile(CompilerInstance &Instance,
12561251
return buildModuleFromInterface(Invocation, Instance);
12571252

12581253
if (Invocation.getInputKind() == InputFileKind::LLVM)
1259-
return compileLLVMIR(Invocation, Instance, Stats);
1254+
return compileLLVMIR(Invocation, Instance);
12601255

12611256
if (FrontendOptions::shouldActionOnlyParse(Action)) {
12621257
// Disable delayed parsing of type and function bodies when we've been
@@ -1284,8 +1279,9 @@ static bool performCompile(CompilerInstance &Instance,
12841279
if (observer)
12851280
observer->performedSemanticAnalysis(Instance);
12861281

1287-
if (Stats)
1282+
if (auto *Stats = Context.Stats) {
12881283
countStatsPostSema(*Stats, Instance);
1284+
}
12891285

12901286
{
12911287
FrontendOptions::DebugCrashMode CrashMode = opts.CrashMode;
@@ -1358,7 +1354,7 @@ static bool performCompile(CompilerInstance &Instance,
13581354
"All actions not requiring SILGen must have been handled!");
13591355

13601356
return performCompileStepsPostSema(Invocation, Instance, moduleIsPublic,
1361-
ReturnValue, observer, Stats);
1357+
ReturnValue, observer);
13621358
}
13631359

13641360
static bool serializeSIB(SILModule *SM, const PrimarySpecificPaths &PSPs,
@@ -1467,8 +1463,7 @@ static bool validateTBDIfNeeded(const CompilerInvocation &Invocation,
14671463
static bool generateCode(const CompilerInvocation &Invocation,
14681464
CompilerInstance &Instance, StringRef OutputFilename,
14691465
llvm::Module *IRModule,
1470-
llvm::GlobalVariable *HashGlobal,
1471-
UnifiedStatsReporter *Stats) {
1466+
llvm::GlobalVariable *HashGlobal) {
14721467
std::unique_ptr<llvm::TargetMachine> TargetMachine = createTargetMachine(
14731468
Invocation.getIRGenOptions(), Instance.getASTContext());
14741469
version::Version EffectiveLanguageVersion =
@@ -1489,9 +1484,10 @@ static bool generateCode(const CompilerInvocation &Invocation,
14891484
}
14901485

14911486
// 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(),
14931488
nullptr, HashGlobal, IRModule, TargetMachine.get(),
1494-
EffectiveLanguageVersion, OutputFilename, Stats);
1489+
EffectiveLanguageVersion, OutputFilename,
1490+
Instance.getStatsReporter());
14951491
}
14961492

14971493
static void collectLinkerDirectives(const CompilerInvocation &Invocation,
@@ -1509,8 +1505,7 @@ static bool performCompileStepsPostSILGen(
15091505
CompilerInstance &Instance, const CompilerInvocation &Invocation,
15101506
std::unique_ptr<SILModule> SM, bool astGuaranteedToCorrespondToSIL,
15111507
ModuleOrSourceFile MSF, const PrimarySpecificPaths &PSPs,
1512-
bool moduleIsPublic, int &ReturnValue, FrontendObserver *observer,
1513-
UnifiedStatsReporter *Stats) {
1508+
bool moduleIsPublic, int &ReturnValue, FrontendObserver *observer) {
15141509

15151510
FrontendOptions opts = Invocation.getFrontendOptions();
15161511
FrontendOptions::ActionType Action = opts.RequestedAction;
@@ -1525,6 +1520,7 @@ static bool performCompileStepsPostSILGen(
15251520
if (observer)
15261521
observer->performedSILGeneration(*SM);
15271522

1523+
auto *Stats = Instance.getASTContext().Stats;
15281524
if (Stats)
15291525
countStatsPostSILGen(*Stats, *SM);
15301526

@@ -1568,7 +1564,7 @@ static bool performCompileStepsPostSILGen(
15681564
SM->setSerializeSILAction(SerializeSILModuleAction);
15691565

15701566
// Perform optimizations and mandatory/diagnostic passes.
1571-
if (Instance.performSILProcessing(SM.get(), Stats))
1567+
if (Instance.performSILProcessing(SM.get()))
15721568
return true;
15731569

15741570
if (observer)
@@ -1662,7 +1658,7 @@ static bool performCompileStepsPostSILGen(
16621658
return true;
16631659

16641660
return generateCode(Invocation, Instance, OutputFilename, IRModule.get(),
1665-
HashGlobal, Stats) ||
1661+
HashGlobal) ||
16661662
HadError;
16671663
}
16681664

@@ -2146,8 +2142,7 @@ int swift::performFrontend(ArrayRef<const char *> Args,
21462142

21472143
int ReturnValue = 0;
21482144
bool HadError =
2149-
performCompile(*Instance, Invocation, Args, ReturnValue, observer,
2150-
StatsReporter.get());
2145+
performCompile(*Instance, Invocation, Args, ReturnValue, observer);
21512146

21522147
if (!HadError) {
21532148
Mangle::printManglingStats();
@@ -2175,7 +2170,7 @@ int swift::performFrontend(ArrayRef<const char *> Args,
21752170
}
21762171

21772172
auto r = finishDiagProcessing(HadError ? 1 : ReturnValue);
2178-
if (StatsReporter)
2173+
if (auto *StatsReporter = Instance->getStatsReporter())
21792174
StatsReporter->noteCurrentProcessExitStatus(r);
21802175
return r;
21812176
}

0 commit comments

Comments
 (0)