[Stats] Warn on failure-to-write stats / trace files.

This commit is contained in:
Graydon Hoare
2017-10-05 19:06:06 -04:00
parent b954f99220
commit 5d08866e56
2 changed files with 12 additions and 2 deletions

View File

@@ -361,8 +361,11 @@ UnifiedStatsReporter::~UnifiedStatsReporter()
std::error_code EC;
raw_fd_ostream ostream(StatsFilename, EC, fs::F_Append | fs::F_Text);
if (EC)
if (EC) {
llvm::errs() << "Error opening -stats-output-dir file '"
<< TraceFilename << "' for writing\n";
return;
}
// We change behavior here depending on whether -DLLVM_ENABLE_STATS and/or
// assertions were on in this build; this is somewhat subtle, but turning on
@@ -387,8 +390,11 @@ UnifiedStatsReporter::~UnifiedStatsReporter()
if (LastTracedFrontendCounters && SourceMgr) {
std::error_code EC;
raw_fd_ostream tstream(TraceFilename, EC, fs::F_Append | fs::F_Text);
if (EC)
if (EC) {
llvm::errs() << "Error opening -trace-stats-events file '"
<< TraceFilename << "' for writing\n";
return;
}
tstream << "Time,Live,IsEntry,EventName,CounterName,"
<< "CounterDelta,CounterValue,SourceRange\n";
for (auto const &E : FrontendStatsEvents) {

View File

@@ -23,10 +23,14 @@
// RUN: %FileCheck -input-file %t/driver.csv %s
// RUN: %utils/process-stats-dir.py --compare-to-csv-baseline %t/driver.csv %t
// RUN: %target-swiftc_driver -c -o %t/out.o -stats-output-dir %t/this/is/not/a/directory %s 2>&1 | %FileCheck -check-prefix=CHECK-NODIR %s
// CHECK: {{"AST.NumSourceLines" [1-9][0-9]*$}}
// CHECK: {{"IRModule.NumIRFunctions" [1-9][0-9]*$}}
// CHECK: {{"LLVM.NumLLVMBytesOutput" [1-9][0-9]*$}}
// CHECK-NODIR: {{Error opening -stats-output-dir file}}
public func foo() {
print("hello")
}