Skip to content

Commit dd85e94

Browse files
committed
[Stats] Replace nonstandard SharedTimers with FrontendStatsTracers.
1 parent 8192759 commit dd85e94

File tree

5 files changed

+18
-12
lines changed

5 files changed

+18
-12
lines changed

include/swift/Basic/Statistic.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ class FrontendStatsTracer
185185
/// entity type, and produce a tracer that's either active or inert depending
186186
/// on whether the provided \p Reporter is null (nullptr means "tracing is
187187
/// disabled").
188+
FrontendStatsTracer(UnifiedStatsReporter *Reporter, StringRef EventName);
188189
FrontendStatsTracer(UnifiedStatsReporter *Reporter, StringRef EventName,
189190
const Decl *D);
190191
FrontendStatsTracer(UnifiedStatsReporter *Reporter, StringRef EventName,

lib/AST/ASTContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1402,7 +1402,7 @@ void ASTContext::loadObjCMethods(
14021402

14031403
void ASTContext::verifyAllLoadedModules() const {
14041404
#ifndef NDEBUG
1405-
SharedTimer("verifyAllLoadedModules");
1405+
FrontendStatsTracer tracer(Stats, "verify-all-loaded-modules");
14061406
for (auto &loader : Impl.ModuleLoaders)
14071407
loader->verifyAllModules();
14081408

lib/Basic/Statistic.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,10 @@ FrontendStatsTracer::FrontendStatsTracer(
296296

297297
FrontendStatsTracer::FrontendStatsTracer() = default;
298298

299+
FrontendStatsTracer::FrontendStatsTracer(UnifiedStatsReporter *R, StringRef S)
300+
: FrontendStatsTracer(R, S, nullptr, nullptr)
301+
{}
302+
299303
FrontendStatsTracer::FrontendStatsTracer(UnifiedStatsReporter *R, StringRef S,
300304
const Decl *D)
301305
: FrontendStatsTracer(R, S, D, getTraceFormatter<const Decl *>())

lib/Frontend/Frontend.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ shouldImplicityImportSwiftOnoneSupportModule(CompilerInvocation &Invocation) {
391391
}
392392

393393
void CompilerInstance::performSema() {
394-
SharedTimer timer("performSema");
394+
FrontendStatsTracer tracer(Context->Stats, "perform-sema");
395395
Context->LoadedModules[MainModule->getName()] = getMainModule();
396396

397397
if (Invocation.getInputKind() == InputFileKind::IFK_SIL) {
@@ -439,7 +439,7 @@ CompilerInstance::ImplicitImports::ImplicitImports(CompilerInstance &compiler) {
439439
}
440440

441441
bool CompilerInstance::loadStdlib() {
442-
SharedTimer timer("performSema-loadStdlib");
442+
FrontendStatsTracer tracer(Context->Stats, "load-stdlib");
443443
ModuleDecl *M = Context->getStdlibModule(true);
444444

445445
if (!M) {
@@ -458,7 +458,7 @@ bool CompilerInstance::loadStdlib() {
458458
}
459459

460460
ModuleDecl *CompilerInstance::importUnderlyingModule() {
461-
SharedTimer timer("performSema-importUnderlyingModule");
461+
FrontendStatsTracer tracer(Context->Stats, "import-underlying-module");
462462
ModuleDecl *objCModuleUnderlyingMixedFramework =
463463
static_cast<ClangImporter *>(Context->getClangModuleLoader())
464464
->loadModule(SourceLoc(),
@@ -471,7 +471,7 @@ ModuleDecl *CompilerInstance::importUnderlyingModule() {
471471
}
472472

473473
ModuleDecl *CompilerInstance::importBridgingHeader() {
474-
SharedTimer timer("performSema-importBridgingHeader");
474+
FrontendStatsTracer tracer(Context->Stats, "import-bridging-header");
475475
const StringRef implicitHeaderPath =
476476
Invocation.getFrontendOptions().ImplicitObjCHeaderPath;
477477
auto clangImporter =
@@ -486,7 +486,7 @@ ModuleDecl *CompilerInstance::importBridgingHeader() {
486486

487487
void CompilerInstance::getImplicitlyImportedModules(
488488
SmallVectorImpl<ModuleDecl *> &importModules) {
489-
SharedTimer timer("performSema-getImplicitlyImportedModules");
489+
FrontendStatsTracer tracer(Context->Stats, "get-implicitly-imported-modules");
490490
for (auto &ImplicitImportModuleName :
491491
Invocation.getFrontendOptions().ImplicitImportModuleNames) {
492492
if (Lexer::isIdentifier(ImplicitImportModuleName)) {
@@ -542,7 +542,7 @@ void CompilerInstance::addMainFileToModule(
542542

543543
void CompilerInstance::parseAndCheckTypes(
544544
const ImplicitImports &implicitImports) {
545-
SharedTimer timer("performSema-parseAndCheckTypes");
545+
FrontendStatsTracer tracer(Context->Stats, "parse-and-check-types");
546546
// Delayed parsing callback for the primary file, or all files
547547
// in non-WMO mode.
548548
std::unique_ptr<DelayedParsingCallbacks> PrimaryDelayedCB{
@@ -606,7 +606,7 @@ void CompilerInstance::parseLibraryFile(
606606
PersistentParserState &PersistentState,
607607
DelayedParsingCallbacks *PrimaryDelayedCB,
608608
DelayedParsingCallbacks *SecondaryDelayedCB) {
609-
SharedTimer timer("performSema-parseLibraryFile");
609+
FrontendStatsTracer tracer(Context->Stats, "parse-library-file");
610610

611611
auto *NextInput = createSourceFileForMainModule(
612612
SourceFileKind::Library, implicitImports.kind, BufferID);
@@ -660,7 +660,8 @@ bool CompilerInstance::parsePartialModulesAndLibraryFiles(
660660
PersistentParserState &PersistentState,
661661
DelayedParsingCallbacks *PrimaryDelayedCB,
662662
DelayedParsingCallbacks *SecondaryDelayedCB) {
663-
SharedTimer timer("performSema-parsePartialModulesAndLibraryFiles");
663+
FrontendStatsTracer tracer(Context->Stats,
664+
"parse-partial-modules-and-library-files");
664665
bool hadLoadError = false;
665666
// Parse all the partial modules first.
666667
for (auto &PM : PartialModules) {
@@ -684,8 +685,8 @@ void CompilerInstance::parseAndTypeCheckMainFile(
684685
PersistentParserState &PersistentState,
685686
DelayedParsingCallbacks *DelayedParseCB,
686687
OptionSet<TypeCheckingFlags> TypeCheckOptions) {
687-
SharedTimer timer(
688-
"performSema-checkTypesWhileParsingMain-parseAndTypeCheckMainFile");
688+
FrontendStatsTracer tracer(Context->Stats,
689+
"parse-and-typecheck-main-file");
689690
bool mainIsPrimary =
690691
(isWholeModuleCompilation() || isPrimaryInput(MainBufferID));
691692

lib/Sema/TypeChecker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,8 +694,8 @@ void swift::performTypeChecking(SourceFile &SF, TopLevelContext &TLC,
694694
}
695695

696696
void swift::performWholeModuleTypeChecking(SourceFile &SF) {
697-
SharedTimer("performWholeModuleTypeChecking");
698697
auto &Ctx = SF.getASTContext();
698+
FrontendStatsTracer tracer(Ctx.Stats, "perform-whole-module-type-checking");
699699
Ctx.diagnoseAttrsRequiringFoundation(SF);
700700
Ctx.diagnoseObjCMethodConflicts(SF);
701701
Ctx.diagnoseObjCUnsatisfiedOptReqConflicts(SF);

0 commit comments

Comments
 (0)