Merge remote-tracking branch 'origin/master' into master-next

This commit is contained in:
swift-ci
2018-01-24 17:36:48 -08:00
7 changed files with 190 additions and 55 deletions

View File

@@ -13,8 +13,10 @@
#ifndef SWIFT_BASIC_STATISTIC_H
#define SWIFT_BASIC_STATISTIC_H
#include "llvm/ADT/PointerUnion.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/Statistic.h"
#include "swift/AST/Identifier.h"
#include "swift/Basic/SourceLoc.h"
#include "swift/Basic/Timer.h"
@@ -47,8 +49,17 @@
// Generally we make one of these per-process: either early in the life of the
// driver, or early in the life of the frontend.
namespace clang {
class Decl;
class SourceManager;
}
namespace swift {
class Decl;
class Expr;
class SILFunction;
class UnifiedStatsReporter {
public:
@@ -75,14 +86,19 @@ public:
int dummyInstanceVariableToGetConstructorToParse;
};
typedef llvm::PointerUnion4<const Decl*,
const clang::Decl*,
const Expr*,
const SILFunction*> TraceEntity;
struct FrontendStatsTracer
{
UnifiedStatsReporter *Reporter;
llvm::TimeRecord SavedTime;
StringRef Name;
SourceRange Range;
FrontendStatsTracer(StringRef Name,
SourceRange const &Range,
StringRef EventName;
TraceEntity Entity;
FrontendStatsTracer(StringRef EventName,
TraceEntity Entity,
UnifiedStatsReporter *Reporter);
FrontendStatsTracer();
FrontendStatsTracer(FrontendStatsTracer&& other);
@@ -101,7 +117,7 @@ public:
StringRef CounterName;
size_t CounterDelta;
size_t CounterValue;
SourceRange SourceRange;
TraceEntity Entity;
};
private:
@@ -112,6 +128,7 @@ private:
llvm::TimeRecord StartedTime;
std::unique_ptr<llvm::NamedRegionTimer> Timer;
SourceManager *SourceMgr;
clang::SourceManager *ClangSourceMgr;
std::unique_ptr<AlwaysOnDriverCounters> DriverCounters;
std::unique_ptr<AlwaysOnFrontendCounters> FrontendCounters;
std::unique_ptr<AlwaysOnFrontendCounters> LastTracedFrontendCounters;
@@ -126,6 +143,7 @@ private:
StringRef AuxName,
StringRef Directory,
SourceManager *SM,
clang::SourceManager *CSM,
bool TraceEvents);
public:
UnifiedStatsReporter(StringRef ProgramName,
@@ -136,6 +154,7 @@ public:
StringRef OptType,
StringRef Directory,
SourceManager *SM=nullptr,
clang::SourceManager *CSM=nullptr,
bool TraceEvents=false);
~UnifiedStatsReporter();
@@ -143,10 +162,14 @@ public:
AlwaysOnFrontendCounters &getFrontendCounters();
AlwaysOnFrontendRecursiveSharedTimers &getFrontendRecursiveSharedTimers();
void noteCurrentProcessExitStatus(int);
FrontendStatsTracer getStatsTracer(StringRef N,
SourceRange const &R);
void saveAnyFrontendStatsEvents(FrontendStatsTracer const& T,
bool IsEntry);
// We provide 4 explicit overloads here, rather than a single function that
// takes a TraceEntity, to save all of our clients from having to include all
// 4 headers that define these 4 forward-declared types.
FrontendStatsTracer getStatsTracer(StringRef EventName, const Decl *D);
FrontendStatsTracer getStatsTracer(StringRef EventName, const clang::Decl*D);
FrontendStatsTracer getStatsTracer(StringRef EventName, const Expr *E);
FrontendStatsTracer getStatsTracer(StringRef EventName, const SILFunction *F);
void saveAnyFrontendStatsEvents(FrontendStatsTracer const &T, bool IsEntry);
};
}