From: Anton Afanasyev Date: Tue, 11 Jun 2019 08:25:54 +0000 (+0000) Subject: [Support][Test] Time profiler: add regression test X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=496a69e981f80192d774727e18d964288352299e;p=clang [Support][Test] Time profiler: add regression test Summary: Add output to `llvm::errs()` when `-ftime-trace` option is enabled, add regression test checking this option works as expected. Reviewers: thakis, aganea Subscribers: cfe-commits, llvm-commits Tags: #clang, #llvm This is recommit of r362821 Differential Revision: https://reviews.llvm.org/D61914 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@363036 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/Driver/check-time-trace.cpp b/test/Driver/check-time-trace.cpp new file mode 100644 index 0000000000..2b6579ee55 --- /dev/null +++ b/test/Driver/check-time-trace.cpp @@ -0,0 +1,28 @@ +// 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: | %python -c 'import json, sys; json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \ +// RUN: | FileCheck %s + +// CHECK: "traceEvents": [ +// CHECK: "args": +// CHECK: "detail": +// CHECK: "dur": +// CHECK: "name": +// CHECK-NEXT: "ph": +// CHECK-NEXT: "pid": +// CHECK-NEXT: "tid": +// CHECK-NEXT: "ts": +// CHECK: "name": "clang" +// CHECK: "name": "process_name" + +template +struct Struct { + T Num; +}; + +int main() { + Struct S; + + return 0; +} diff --git a/tools/driver/cc1_main.cpp b/tools/driver/cc1_main.cpp index ae60fefdcf..caf73195fe 100644 --- a/tools/driver/cc1_main.cpp +++ b/tools/driver/cc1_main.cpp @@ -241,6 +241,11 @@ int cc1_main(ArrayRef Argv, const char *Argv0, void *MainAddr) { llvm::timeTraceProfilerWrite(*profilerOutput); llvm::timeTraceProfilerCleanup(); + + llvm::errs() << "Time trace json-file dumped to " << Path.str() << "\n"; + llvm::errs() + << "Use chrome://tracing or Speedscope App " + "(https://www.speedscope.app) for flamegraph visualization\n"; } // Our error handler depends on the Diagnostics object, which we're