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
--- /dev/null
+// 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 <typename T>
+struct Struct {
+ T Num;
+};
+
+int main() {
+ Struct<int> S;
+
+ return 0;
+}
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