Skip to content

Commit 0167821

Browse files
committed
[Stats] Add some tracers to SILGen.
1 parent 559c8e7 commit 0167821

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

lib/SILGen/SILGen.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ void SILGenModule::emitFunction(FuncDecl *fd) {
719719
emitAbstractFuncDecl(fd);
720720

721721
if (hasSILBody(fd)) {
722-
FrontendStatsTracer Tracer(getASTContext().Stats, "emit-SIL", fd);
722+
FrontendStatsTracer Tracer(getASTContext().Stats, "SILGen-funcdecl", fd);
723723
PrettyStackTraceDecl stackTrace("emitting SIL for", fd);
724724

725725
SILDeclRef constant(decl);
@@ -1536,11 +1536,16 @@ class SourceFileScope {
15361536

15371537
void SILGenModule::emitSourceFile(SourceFile *sf, unsigned startElem) {
15381538
SourceFileScope scope(*this, sf);
1539-
for (Decl *D : llvm::makeArrayRef(sf->Decls).slice(startElem))
1539+
FrontendStatsTracer StatsTracer(getASTContext().Stats, "SILgen-file", sf);
1540+
for (Decl *D : llvm::makeArrayRef(sf->Decls).slice(startElem)) {
1541+
FrontendStatsTracer StatsTracer(getASTContext().Stats, "SILgen-decl", D);
15401542
visit(D);
1543+
}
15411544

1542-
for (Decl *D : sf->LocalTypeDecls)
1545+
for (Decl *D : sf->LocalTypeDecls) {
1546+
FrontendStatsTracer StatsTracer(getASTContext().Stats, "SILgen-tydecl", D);
15431547
visit(D);
1548+
}
15441549

15451550
// Mark any conformances as "used".
15461551
for (auto conformance : sf->getUsedConformances())

lib/SILGen/SILGenFunction.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ using namespace Lowering;
3333
SILGenFunction::SILGenFunction(SILGenModule &SGM, SILFunction &F)
3434
: SGM(SGM), F(F), silConv(SGM.M), StartOfPostmatter(F.end()),
3535
B(*this), OpenedArchetypesTracker(&F),
36-
CurrentSILLoc(F.getLocation()), Cleanups(*this) {
36+
CurrentSILLoc(F.getLocation()), Cleanups(*this),
37+
StatsTracer(SGM.M.getASTContext().Stats, "SILGen-function", &F) {
3738
B.setInsertionPoint(createBasicBlock());
3839
B.setCurrentDebugScope(F.getDebugScope());
3940
B.setOpenedArchetypesTracker(&OpenedArchetypesTracker);

lib/SILGen/SILGenFunction.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "SILGenBuilder.h"
2323
#include "swift/AST/AnyFunctionRef.h"
2424
#include "swift/Basic/ProfileCounter.h"
25+
#include "swift/Basic/Statistic.h"
2526
#include "swift/SIL/SILBuilder.h"
2627
#include "llvm/ADT/PointerIntPair.h"
2728

@@ -380,6 +381,9 @@ class LLVM_LIBRARY_VISIBILITY SILGenFunction
380381
/// Get the PGO node's parent.
381382
Optional<ASTNode> getPGOParent(ASTNode Node) const;
382383

384+
/// Tracer object for counting SIL (and other events) caused by this instance.
385+
FrontendStatsTracer StatsTracer;
386+
383387
SILGenFunction(SILGenModule &SGM, SILFunction &F);
384388
~SILGenFunction();
385389

0 commit comments

Comments
 (0)