Skip to content

Commit 994ad7a

Browse files
committed
[stats] Add -trace-stats-events
1 parent 205f725 commit 994ad7a

File tree

5 files changed

+15
-1
lines changed

5 files changed

+15
-1
lines changed

include/swift/Frontend/FrontendOptions.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,9 @@ class FrontendOptions {
220220
/// The path to which we should output statistics files.
221221
std::string StatsOutputDir;
222222

223+
/// Trace changes to stats to files in StatsOutputDir.
224+
bool TraceStats = false;
225+
223226
/// Indicates whether function body parsing should be delayed
224227
/// until the end of all files.
225228
bool DelayedFunctionBodyParsing = false;

include/swift/Option/Options.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,9 @@ def driver_time_compilation : Flag<["-"], "driver-time-compilation">,
194194
def stats_output_dir: Separate<["-"], "stats-output-dir">,
195195
Flags<[FrontendOption, HelpHidden]>,
196196
HelpText<"Directory to write unified compilation-statistics files to">;
197+
def trace_stats_events: Flag<["-"], "trace-stats-events">,
198+
Flags<[FrontendOption, HelpHidden]>,
199+
HelpText<"Trace changes to stats in -stats-output-dir">;
197200

198201
def emit_dependencies : Flag<["-"], "emit-dependencies">,
199202
Flags<[FrontendOption, NoInteractiveOption, DoesNotAffectIncrementalBuild]>,

lib/Driver/ToolChains.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ static void addCommonFrontendArgs(const ToolChain &TC,
151151
inputArgs.AddLastArg(arguments, options::OPT_swift_version);
152152
inputArgs.AddLastArg(arguments, options::OPT_enforce_exclusivity_EQ);
153153
inputArgs.AddLastArg(arguments, options::OPT_stats_output_dir);
154+
inputArgs.AddLastArg(arguments, options::OPT_trace_stats_events);
154155
inputArgs.AddLastArg(arguments,
155156
options::OPT_solver_shrink_unsolved_threshold);
156157
inputArgs.AddLastArg(arguments, options::OPT_O_Group);

lib/Frontend/CompilerInvocation.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,9 @@ static bool ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
194194
Opts.DebugTimeCompilation |= Args.hasArg(OPT_debug_time_compilation);
195195
if (const Arg *A = Args.getLastArg(OPT_stats_output_dir)) {
196196
Opts.StatsOutputDir = A->getValue();
197+
if (Args.getLastArg(OPT_trace_stats_events)) {
198+
Opts.TraceStats = true;
199+
}
197200
}
198201

199202
if (const Arg *A = Args.getLastArg(OPT_validate_tbd_against_ir_EQ)) {

lib/FrontendTool/FrontendTool.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1360,13 +1360,17 @@ int swift::performFrontend(ArrayRef<const char *> Args,
13601360
StringRef OutFile = FEOpts.getSingleOutputFilename();
13611361
StringRef OutputType = llvm::sys::path::extension(OutFile);
13621362
std::string TripleName = LangOpts.Target.normalize();
1363+
auto &SM = Instance->getSourceMgr();
1364+
auto Trace = Invocation.getFrontendOptions().TraceStats;
13631365
StatsReporter = llvm::make_unique<UnifiedStatsReporter>("swift-frontend",
13641366
FEOpts.ModuleName,
13651367
InputName,
13661368
TripleName,
13671369
OutputType,
13681370
OptType,
1369-
StatsOutputDir);
1371+
StatsOutputDir,
1372+
&SM,
1373+
Trace);
13701374
}
13711375

13721376
const DiagnosticOptions &diagOpts = Invocation.getDiagnosticOptions();

0 commit comments

Comments
 (0)