diff --git a/clang/test/Driver/check-time-trace.cpp b/clang/test/Driver/check-time-trace.cpp index 2b6579ee5528..080910893876 100644 --- a/clang/test/Driver/check-time-trace.cpp +++ b/clang/test/Driver/check-time-trace.cpp @@ -1,6 +1,6 @@ // REQUIRES: shell -// RUN: %clangxx -S -ftime-trace -mllvm --time-trace-granularity=0 %s 2>&1 \ -// RUN: | grep "Time trace json-file dumped to" | awk '{print $NF}' | xargs cat \ +// RUN: %clangxx -S -ftime-trace -mllvm --time-trace-granularity=0 -o %T/check-time-trace %s +// RUN: cat %T/check-time-trace.json \ // RUN: | %python -c 'import json, sys; json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \ // RUN: | FileCheck %s diff --git a/clang/tools/driver/cc1_main.cpp b/clang/tools/driver/cc1_main.cpp index caf73195fe54..2ed27c22708a 100644 --- a/clang/tools/driver/cc1_main.cpp +++ b/clang/tools/driver/cc1_main.cpp @@ -240,6 +240,8 @@ int cc1_main(ArrayRef Argv, const char *Argv0, void *MainAddr) { /*useTemporary=*/false); llvm::timeTraceProfilerWrite(*profilerOutput); + // FIXME(ibiryukov): make profilerOutput flush in destructor instead. + profilerOutput->flush(); llvm::timeTraceProfilerCleanup(); llvm::errs() << "Time trace json-file dumped to " << Path.str() << "\n";