Skip to content

Commit bfab9d6

Browse files
authored
Merge pull request #5608 from graydon/statistic-helpers
2 parents 8800c8c + b3e5e80 commit bfab9d6

File tree

4 files changed

+41
-1
lines changed

4 files changed

+41
-1
lines changed

include/swift/Basic/Statistic.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//===--- Statistic.h - Helpers for Lllvm::Statistic ---------*- C++ -*-===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2016 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See http://swift.org/LICENSE.txt for license information
9+
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#ifndef SWIFT_BASIC_STATISTIC_H
14+
#define SWIFT_BASIC_STATISTIC_H
15+
16+
#include "llvm/ADT/Statistic.h"
17+
18+
#define SWIFT_FUNC_STAT \
19+
do { \
20+
static llvm::Statistic FStat = \
21+
{DEBUG_TYPE, __func__, __func__, {0}, false}; \
22+
++FStat; \
23+
} while (0)
24+
25+
#endif // SWIFT_BASIC_STATISTIC_H

lib/Sema/TypeCheckDecl.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "swift/AST/PrettyStackTrace.h"
3232
#include "swift/AST/ReferencedNameTracker.h"
3333
#include "swift/AST/TypeWalker.h"
34+
#include "swift/Basic/Statistic.h"
3435
#include "swift/Parse/Lexer.h"
3536
#include "swift/Parse/Parser.h"
3637
#include "swift/Sema/IterativeTypeChecker.h"
@@ -45,6 +46,8 @@
4546
#include "llvm/ADT/Twine.h"
4647
using namespace swift;
4748

49+
#define DEBUG_TYPE "TypeCheckDecl"
50+
4851
namespace {
4952

5053
/// Used during enum raw value checking to identify duplicate raw values.
@@ -6968,7 +6971,9 @@ void TypeChecker::validateDecl(ValueDecl *D, bool resolveTypeParams) {
69686971
validateExtension(ext);
69696972
}
69706973
}
6971-
6974+
6975+
SWIFT_FUNC_STAT;
6976+
69726977
switch (D->getKind()) {
69736978
case DeclKind::Import:
69746979
case DeclKind::Extension:

lib/Sema/TypeCheckStmt.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "swift/Basic/Range.h"
2626
#include "swift/Basic/STLExtras.h"
2727
#include "swift/Basic/SourceManager.h"
28+
#include "swift/Basic/Statistic.h"
2829
#include "swift/Parse/Lexer.h"
2930
#include "swift/Parse/LocalContext.h"
3031
#include "llvm/ADT/DenseMap.h"
@@ -38,6 +39,8 @@
3839

3940
using namespace swift;
4041

42+
#define DEBUG_TYPE "TypeCheckStmt"
43+
4144
namespace {
4245
class ContextualizeClosures : public ASTWalker {
4346
DeclContext *ParentDC;
@@ -1248,6 +1251,8 @@ bool TypeChecker::typeCheckAbstractFunctionBody(AbstractFunctionDecl *AFD) {
12481251
if (!AFD->getBody())
12491252
return false;
12501253

1254+
SWIFT_FUNC_STAT;
1255+
12511256
Optional<FunctionBodyTimer> timer;
12521257
if (DebugTimeFunctionBodies || WarnLongFunctionBodies)
12531258
timer.emplace(AFD, DebugTimeFunctionBodies, WarnLongFunctionBodies);

lib/Sema/TypeCheckType.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "swift/AST/PrettyStackTrace.h"
2929
#include "swift/AST/TypeLoc.h"
3030
#include "swift/Basic/SourceManager.h"
31+
#include "swift/Basic/Statistic.h"
3132
#include "swift/Basic/StringExtras.h"
3233
#include "swift/ClangImporter/ClangImporter.h"
3334
#include "llvm/ADT/APInt.h"
@@ -37,6 +38,8 @@
3738
#include "llvm/ADT/Twine.h"
3839
using namespace swift;
3940

41+
#define DEBUG_TYPE "TypeCheckType"
42+
4043
GenericTypeResolver::~GenericTypeResolver() { }
4144

4245
Type TypeChecker::getArraySliceType(SourceLoc loc, Type elementType) {
@@ -1526,6 +1529,8 @@ bool TypeChecker::validateType(TypeLoc &Loc, DeclContext *DC,
15261529
if (Loc.wasValidated())
15271530
return Loc.isError();
15281531

1532+
SWIFT_FUNC_STAT;
1533+
15291534
if (Loc.getType().isNull()) {
15301535
// Raise error if we parse an IUO type in an illegal position.
15311536
checkForIllegalIUOs(*this, Loc.getTypeRepr(), options);

0 commit comments

Comments
 (0)