[NFC] Remove the stats reporter parameter from FrontendTool entrypoints

Now that the CompilerInstance owns the stats reporter, use that instead.
This commit is contained in:
Robert Widmann
2020-02-27 16:04:42 -08:00
parent de72824b04
commit 7dd000bdb5

View File

@@ -788,8 +788,7 @@ static bool buildModuleFromInterface(const CompilerInvocation &Invocation,
}
static bool compileLLVMIR(const CompilerInvocation &Invocation,
CompilerInstance &Instance,
UnifiedStatsReporter *Stats) {
CompilerInstance &Instance) {
auto &LLVMContext = getGlobalLLVMContext();
// Load in bitcode file.
@@ -826,8 +825,7 @@ static bool compileLLVMIR(const CompilerInvocation &Invocation,
return performLLVM(Invocation.getIRGenOptions(),
Instance.getASTContext(), Module.get(),
Invocation.getFrontendOptions()
.InputsAndOutputs.getSingleOutputFilename(),
Stats);
.InputsAndOutputs.getSingleOutputFilename());
}
static void verifyGenericSignaturesIfNeeded(const CompilerInvocation &Invocation,
@@ -1085,15 +1083,13 @@ static bool performCompileStepsPostSILGen(
CompilerInstance &Instance, const CompilerInvocation &Invocation,
std::unique_ptr<SILModule> SM, bool astGuaranteedToCorrespondToSIL,
ModuleOrSourceFile MSF, const PrimarySpecificPaths &PSPs,
bool moduleIsPublic, int &ReturnValue, FrontendObserver *observer,
UnifiedStatsReporter *Stats);
bool moduleIsPublic, int &ReturnValue, FrontendObserver *observer);
static bool
performCompileStepsPostSema(const CompilerInvocation &Invocation,
CompilerInstance &Instance,
bool moduleIsPublic, int &ReturnValue,
FrontendObserver *observer,
UnifiedStatsReporter *Stats) {
FrontendObserver *observer) {
auto mod = Instance.getMainModule();
if (auto SM = Instance.takeSILModule()) {
const PrimarySpecificPaths PSPs =
@@ -1101,7 +1097,7 @@ performCompileStepsPostSema(const CompilerInvocation &Invocation,
return performCompileStepsPostSILGen(Instance, Invocation, std::move(SM),
/*ASTGuaranteedToCorrespondToSIL=*/false,
mod, PSPs, moduleIsPublic,
ReturnValue, observer, Stats);
ReturnValue, observer);
}
const SILOptions &SILOpts = Invocation.getSILOptions();
@@ -1122,7 +1118,7 @@ performCompileStepsPostSema(const CompilerInvocation &Invocation,
return performCompileStepsPostSILGen(Instance, Invocation, std::move(SM),
astGuaranteedToCorrespondToSIL,
mod, PSPs, moduleIsPublic,
ReturnValue, observer, Stats);
ReturnValue, observer);
}
// If there are primary source files, build a separate SILModule for
// each source file, and run the remaining SILOpt-Serialize-IRGen-LLVM
@@ -1136,7 +1132,7 @@ performCompileStepsPostSema(const CompilerInvocation &Invocation,
result |= performCompileStepsPostSILGen(Instance, Invocation, std::move(SM),
/*ASTGuaranteedToCorrespondToSIL*/true,
PrimaryFile, PSPs, moduleIsPublic,
ReturnValue, observer, Stats);
ReturnValue, observer);
}
return result;
@@ -1155,7 +1151,7 @@ performCompileStepsPostSema(const CompilerInvocation &Invocation,
result |= performCompileStepsPostSILGen(Instance, Invocation, std::move(SM),
!fileIsSIB(SASTF),
mod, PSPs, moduleIsPublic,
ReturnValue, observer, Stats);
ReturnValue, observer);
}
}
@@ -1233,8 +1229,7 @@ static bool performCompile(CompilerInstance &Instance,
const CompilerInvocation &Invocation,
ArrayRef<const char *> Args,
int &ReturnValue,
FrontendObserver *observer,
UnifiedStatsReporter *Stats) {
FrontendObserver *observer) {
FrontendOptions opts = Invocation.getFrontendOptions();
FrontendOptions::ActionType Action = opts.RequestedAction;
@@ -1256,7 +1251,7 @@ static bool performCompile(CompilerInstance &Instance,
return buildModuleFromInterface(Invocation, Instance);
if (Invocation.getInputKind() == InputFileKind::LLVM)
return compileLLVMIR(Invocation, Instance, Stats);
return compileLLVMIR(Invocation, Instance);
if (FrontendOptions::shouldActionOnlyParse(Action)) {
// Disable delayed parsing of type and function bodies when we've been
@@ -1284,8 +1279,9 @@ static bool performCompile(CompilerInstance &Instance,
if (observer)
observer->performedSemanticAnalysis(Instance);
if (Stats)
if (auto *Stats = Context.Stats) {
countStatsPostSema(*Stats, Instance);
}
{
FrontendOptions::DebugCrashMode CrashMode = opts.CrashMode;
@@ -1358,7 +1354,7 @@ static bool performCompile(CompilerInstance &Instance,
"All actions not requiring SILGen must have been handled!");
return performCompileStepsPostSema(Invocation, Instance, moduleIsPublic,
ReturnValue, observer, Stats);
ReturnValue, observer);
}
static bool serializeSIB(SILModule *SM, const PrimarySpecificPaths &PSPs,
@@ -1467,8 +1463,7 @@ static bool validateTBDIfNeeded(const CompilerInvocation &Invocation,
static bool generateCode(const CompilerInvocation &Invocation,
CompilerInstance &Instance, StringRef OutputFilename,
llvm::Module *IRModule,
llvm::GlobalVariable *HashGlobal,
UnifiedStatsReporter *Stats) {
llvm::GlobalVariable *HashGlobal) {
std::unique_ptr<llvm::TargetMachine> TargetMachine = createTargetMachine(
Invocation.getIRGenOptions(), Instance.getASTContext());
version::Version EffectiveLanguageVersion =
@@ -1489,9 +1484,10 @@ static bool generateCode(const CompilerInvocation &Invocation,
}
// Now that we have a single IR Module, hand it over to performLLVM.
return performLLVM(Invocation.getIRGenOptions(), &Instance.getDiags(),
return performLLVM(Invocation.getIRGenOptions(), Instance.getDiags(),
nullptr, HashGlobal, IRModule, TargetMachine.get(),
EffectiveLanguageVersion, OutputFilename, Stats);
EffectiveLanguageVersion, OutputFilename,
Instance.getStatsReporter());
}
static void collectLinkerDirectives(const CompilerInvocation &Invocation,
@@ -1509,8 +1505,7 @@ static bool performCompileStepsPostSILGen(
CompilerInstance &Instance, const CompilerInvocation &Invocation,
std::unique_ptr<SILModule> SM, bool astGuaranteedToCorrespondToSIL,
ModuleOrSourceFile MSF, const PrimarySpecificPaths &PSPs,
bool moduleIsPublic, int &ReturnValue, FrontendObserver *observer,
UnifiedStatsReporter *Stats) {
bool moduleIsPublic, int &ReturnValue, FrontendObserver *observer) {
FrontendOptions opts = Invocation.getFrontendOptions();
FrontendOptions::ActionType Action = opts.RequestedAction;
@@ -1525,6 +1520,7 @@ static bool performCompileStepsPostSILGen(
if (observer)
observer->performedSILGeneration(*SM);
auto *Stats = Instance.getASTContext().Stats;
if (Stats)
countStatsPostSILGen(*Stats, *SM);
@@ -1568,7 +1564,7 @@ static bool performCompileStepsPostSILGen(
SM->setSerializeSILAction(SerializeSILModuleAction);
// Perform optimizations and mandatory/diagnostic passes.
if (Instance.performSILProcessing(SM.get(), Stats))
if (Instance.performSILProcessing(SM.get()))
return true;
if (observer)
@@ -1662,7 +1658,7 @@ static bool performCompileStepsPostSILGen(
return true;
return generateCode(Invocation, Instance, OutputFilename, IRModule.get(),
HashGlobal, Stats) ||
HashGlobal) ||
HadError;
}
@@ -2146,8 +2142,7 @@ int swift::performFrontend(ArrayRef<const char *> Args,
int ReturnValue = 0;
bool HadError =
performCompile(*Instance, Invocation, Args, ReturnValue, observer,
StatsReporter.get());
performCompile(*Instance, Invocation, Args, ReturnValue, observer);
if (!HadError) {
Mangle::printManglingStats();
@@ -2175,7 +2170,7 @@ int swift::performFrontend(ArrayRef<const char *> Args,
}
auto r = finishDiagProcessing(HadError ? 1 : ReturnValue);
if (StatsReporter)
if (auto *StatsReporter = Instance->getStatsReporter())
StatsReporter->noteCurrentProcessExitStatus(r);
return r;
}