summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/TimeProfiler.cpp
diff options
context:
space:
mode:
authorRussell Gallop <russell.gallop@sony.com>2019-12-02 13:10:44 +0000
committerRussell Gallop <russell.gallop@sony.com>2019-12-03 13:04:27 +0000
commitaedeab7f85caaa0946152e5d73e37455267019bb (patch)
tree44d0d31aa30284d7a4d869f6c553b06828dfb783 /llvm/lib/Support/TimeProfiler.cpp
parent7caa17caf8e290fb865ac81470da737056ab0ace (diff)
downloadbcm5719-llvm-aedeab7f85caaa0946152e5d73e37455267019bb.tar.gz
bcm5719-llvm-aedeab7f85caaa0946152e5d73e37455267019bb.zip
[Support] Add ProcName to TimeTraceProfiler
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. Differential Revision: https://reviews.llvm.org/D70950
Diffstat (limited to 'llvm/lib/Support/TimeProfiler.cpp')
-rw-r--r--llvm/lib/Support/TimeProfiler.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/llvm/lib/Support/TimeProfiler.cpp b/llvm/lib/Support/TimeProfiler.cpp
index fc9ad162699..6c993387e59 100644
--- a/llvm/lib/Support/TimeProfiler.cpp
+++ b/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 <cassert>
#include <chrono>
#include <string>
@@ -58,8 +59,8 @@ struct Entry {
};
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<std::string()> Detail) {
@@ -167,7 +168,7 @@ struct TimeTraceProfiler {
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 @@ struct TimeTraceProfiler {
SmallVector<Entry, 128> Entries;
StringMap<CountAndDurationType> 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() {
OpenPOWER on IntegriCloud