[PATCH] D70950: Add ProcName to TimeTraceProfiler

2020-01-31 Thread Russell Gallop via Phabricator via cfe-commits
russell.gallop added a comment.

In D70950#1850796 , @rnk wrote:

> This broke ClangBuildAnalyzer on Windows because it has a very naive check 
> for "clang":
>  https://github.com/aras-p/ClangBuildAnalyzer/blob/master/src/main.cpp#L148
>  I was wondering why this wasn't working on Windows anymore. =/


I think this should be fixed by this recent change to ClangBuildAnalyzer: 
https://github.com/aras-p/ClangBuildAnalyzer/commit/7ccac789ba5846c04392755a71856b18b7f0c2c1

That should cope with both clang-11 and clang.exe.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70950/new/

https://reviews.llvm.org/D70950



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70950: Add ProcName to TimeTraceProfiler

2020-01-30 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

This broke ClangBuildAnalyzer on Windows because it has a very naive check for 
"clang":
https://github.com/aras-p/ClangBuildAnalyzer/blob/master/src/main.cpp#L148
I was wondering why this wasn't working on Windows anymore. =/


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70950/new/

https://reviews.llvm.org/D70950



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70950: Add ProcName to TimeTraceProfiler

2019-12-03 Thread Russell Gallop via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGaedeab7f85ca: [Support] Add ProcName to TimeTraceProfiler 
(authored by russell.gallop).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70950/new/

https://reviews.llvm.org/D70950

Files:
  clang/test/Driver/check-time-trace.cpp
  clang/tools/driver/cc1_main.cpp
  llvm/include/llvm/Support/TimeProfiler.h
  llvm/lib/Support/TimeProfiler.cpp


Index: llvm/lib/Support/TimeProfiler.cpp
===
--- llvm/lib/Support/TimeProfiler.cpp
+++ llvm/lib/Support/TimeProfiler.cpp
@@ -14,6 +14,7 @@
 #include "llvm/ADT/StringMap.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/JSON.h"
+#include "llvm/Support/Path.h"
 #include 
 #include 
 #include 
@@ -58,8 +59,8 @@
 };
 
 struct TimeTraceProfiler {
-  TimeTraceProfiler(unsigned TimeTraceGranularity = 0)
-  : StartTime(steady_clock::now()),
+  TimeTraceProfiler(unsigned TimeTraceGranularity = 0, StringRef ProcName = "")
+  : StartTime(steady_clock::now()), ProcName(ProcName),
 TimeTraceGranularity(TimeTraceGranularity) {}
 
   void begin(std::string Name, llvm::function_ref Detail) {
@@ -167,7 +168,7 @@
   J.attribute("ts", 0);
   J.attribute("ph", "M");
   J.attribute("name", "process_name");
-  J.attributeObject("args", [&] { J.attribute("name", "clang"); });
+  J.attributeObject("args", [&] { J.attribute("name", ProcName); });
 });
 
 J.arrayEnd();
@@ -179,15 +180,18 @@
   SmallVector Entries;
   StringMap CountAndTotalPerName;
   const TimePointType StartTime;
+  const std::string ProcName;
 
   // Minimum time granularity (in microseconds)
   const unsigned TimeTraceGranularity;
 };
 
-void timeTraceProfilerInitialize(unsigned TimeTraceGranularity) {
+void timeTraceProfilerInitialize(unsigned TimeTraceGranularity,
+ StringRef ProcName) {
   assert(TimeTraceProfilerInstance == nullptr &&
  "Profiler should not be initialized");
-  TimeTraceProfilerInstance = new TimeTraceProfiler(TimeTraceGranularity);
+  TimeTraceProfilerInstance = new TimeTraceProfiler(
+  TimeTraceGranularity, llvm::sys::path::filename(ProcName));
 }
 
 void timeTraceProfilerCleanup() {
Index: llvm/include/llvm/Support/TimeProfiler.h
===
--- llvm/include/llvm/Support/TimeProfiler.h
+++ llvm/include/llvm/Support/TimeProfiler.h
@@ -19,7 +19,8 @@
 /// Initialize the time trace profiler.
 /// This sets up the global \p TimeTraceProfilerInstance
 /// variable to be the profiler instance.
-void timeTraceProfilerInitialize(unsigned TimeTraceGranularity);
+void timeTraceProfilerInitialize(unsigned TimeTraceGranularity,
+ StringRef ProcName);
 
 /// Cleanup the time trace profiler, if it was initialized.
 void timeTraceProfilerCleanup();
Index: clang/tools/driver/cc1_main.cpp
===
--- clang/tools/driver/cc1_main.cpp
+++ clang/tools/driver/cc1_main.cpp
@@ -218,7 +218,7 @@
 
   if (Clang->getFrontendOpts().TimeTrace) {
 llvm::timeTraceProfilerInitialize(
-Clang->getFrontendOpts().TimeTraceGranularity);
+Clang->getFrontendOpts().TimeTraceGranularity, Argv0);
   }
   // --print-supported-cpus takes priority over the actual compilation.
   if (Clang->getFrontendOpts().PrintSupportedCPUs)
Index: clang/test/Driver/check-time-trace.cpp
===
--- clang/test/Driver/check-time-trace.cpp
+++ clang/test/Driver/check-time-trace.cpp
@@ -12,7 +12,7 @@
 // CHECK-NEXT: "pid":
 // CHECK-NEXT: "tid":
 // CHECK-NEXT: "ts":
-// CHECK: "name": "clang"
+// CHECK: "name": "clang{{.*}}"
 // CHECK: "name": "process_name"
 
 template 


Index: llvm/lib/Support/TimeProfiler.cpp
===
--- llvm/lib/Support/TimeProfiler.cpp
+++ llvm/lib/Support/TimeProfiler.cpp
@@ -14,6 +14,7 @@
 #include "llvm/ADT/StringMap.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/JSON.h"
+#include "llvm/Support/Path.h"
 #include 
 #include 
 #include 
@@ -58,8 +59,8 @@
 };
 
 struct TimeTraceProfiler {
-  TimeTraceProfiler(unsigned TimeTraceGranularity = 0)
-  : StartTime(steady_clock::now()),
+  TimeTraceProfiler(unsigned TimeTraceGranularity = 0, StringRef ProcName = "")
+  : StartTime(steady_clock::now()), ProcName(ProcName),
 TimeTraceGranularity(TimeTraceGranularity) {}
 
   void begin(std::string Name, llvm::function_ref Detail) {
@@ -167,7 +168,7 @@
   J.attribute("ts", 0);
   J.attribute("ph", "M");
   J.attribute("name", "process_name");
-  J.attributeObject("args", [&] { J.attribute("name", "clang"); });
+  J.attributeObject("args", [&] { J.attribute("name", ProcName); });
 });
 
 J.arrayEnd();
@@ 

[PATCH] D70950: Add ProcName to TimeTraceProfiler

2019-12-03 Thread Russell Gallop via Phabricator via cfe-commits
russell.gallop created this revision.
russell.gallop added a reviewer: anton-afanasyev.
Herald added subscribers: cfe-commits, hiraditya.
Herald added projects: clang, LLVM.

This was hard-coded to "clang". This change allows it to to be used on 
processes other than clang (such as lld).

This gets reported as clang-10 on Linux and clang.exe on Windows so adapted 
test to accommodate this.

This change is working towards LLD time trace support, RFC here: 
https://reviews.llvm.org/D69043


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70950

Files:
  clang/test/Driver/check-time-trace.cpp
  clang/tools/driver/cc1_main.cpp
  llvm/include/llvm/Support/TimeProfiler.h
  llvm/lib/Support/TimeProfiler.cpp


Index: llvm/lib/Support/TimeProfiler.cpp
===
--- llvm/lib/Support/TimeProfiler.cpp
+++ llvm/lib/Support/TimeProfiler.cpp
@@ -14,6 +14,7 @@
 #include "llvm/ADT/StringMap.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/JSON.h"
+#include "llvm/Support/Path.h"
 #include 
 #include 
 #include 
@@ -58,8 +59,8 @@
 };
 
 struct TimeTraceProfiler {
-  TimeTraceProfiler(unsigned TimeTraceGranularity = 0)
-  : StartTime(steady_clock::now()),
+  TimeTraceProfiler(unsigned TimeTraceGranularity = 0, StringRef ProcName = "")
+  : StartTime(steady_clock::now()), ProcName(ProcName),
 TimeTraceGranularity(TimeTraceGranularity) {}
 
   void begin(std::string Name, llvm::function_ref Detail) {
@@ -167,7 +168,7 @@
   J.attribute("ts", 0);
   J.attribute("ph", "M");
   J.attribute("name", "process_name");
-  J.attributeObject("args", [&] { J.attribute("name", "clang"); });
+  J.attributeObject("args", [&] { J.attribute("name", ProcName); });
 });
 
 J.arrayEnd();
@@ -179,15 +180,18 @@
   SmallVector Entries;
   StringMap CountAndTotalPerName;
   const TimePointType StartTime;
+  const std::string ProcName;
 
   // Minimum time granularity (in microseconds)
   const unsigned TimeTraceGranularity;
 };
 
-void timeTraceProfilerInitialize(unsigned TimeTraceGranularity) {
+void timeTraceProfilerInitialize(unsigned TimeTraceGranularity,
+ StringRef ProcName) {
   assert(TimeTraceProfilerInstance == nullptr &&
  "Profiler should not be initialized");
-  TimeTraceProfilerInstance = new TimeTraceProfiler(TimeTraceGranularity);
+  TimeTraceProfilerInstance = new TimeTraceProfiler(
+  TimeTraceGranularity, llvm::sys::path::filename(ProcName));
 }
 
 void timeTraceProfilerCleanup() {
Index: llvm/include/llvm/Support/TimeProfiler.h
===
--- llvm/include/llvm/Support/TimeProfiler.h
+++ llvm/include/llvm/Support/TimeProfiler.h
@@ -19,7 +19,8 @@
 /// Initialize the time trace profiler.
 /// This sets up the global \p TimeTraceProfilerInstance
 /// variable to be the profiler instance.
-void timeTraceProfilerInitialize(unsigned TimeTraceGranularity);
+void timeTraceProfilerInitialize(unsigned TimeTraceGranularity,
+ StringRef ProcName);
 
 /// Cleanup the time trace profiler, if it was initialized.
 void timeTraceProfilerCleanup();
Index: clang/tools/driver/cc1_main.cpp
===
--- clang/tools/driver/cc1_main.cpp
+++ clang/tools/driver/cc1_main.cpp
@@ -218,7 +218,7 @@
 
   if (Clang->getFrontendOpts().TimeTrace) {
 llvm::timeTraceProfilerInitialize(
-Clang->getFrontendOpts().TimeTraceGranularity);
+Clang->getFrontendOpts().TimeTraceGranularity, Argv0);
   }
   // --print-supported-cpus takes priority over the actual compilation.
   if (Clang->getFrontendOpts().PrintSupportedCPUs)
Index: clang/test/Driver/check-time-trace.cpp
===
--- clang/test/Driver/check-time-trace.cpp
+++ clang/test/Driver/check-time-trace.cpp
@@ -12,7 +12,7 @@
 // CHECK-NEXT: "pid":
 // CHECK-NEXT: "tid":
 // CHECK-NEXT: "ts":
-// CHECK: "name": "clang"
+// CHECK: "name": "clang{{.*}}"
 // CHECK: "name": "process_name"
 
 template 


Index: llvm/lib/Support/TimeProfiler.cpp
===
--- llvm/lib/Support/TimeProfiler.cpp
+++ llvm/lib/Support/TimeProfiler.cpp
@@ -14,6 +14,7 @@
 #include "llvm/ADT/StringMap.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/JSON.h"
+#include "llvm/Support/Path.h"
 #include 
 #include 
 #include 
@@ -58,8 +59,8 @@
 };
 
 struct TimeTraceProfiler {
-  TimeTraceProfiler(unsigned TimeTraceGranularity = 0)
-  : StartTime(steady_clock::now()),
+  TimeTraceProfiler(unsigned TimeTraceGranularity = 0, StringRef ProcName = "")
+  : StartTime(steady_clock::now()), ProcName(ProcName),
 TimeTraceGranularity(TimeTraceGranularity) {}
 
   void begin(std::string Name, llvm::function_ref Detail) {
@@ -167,7 +168,7 @@
   J.attribute("ts", 0);