[PATCH] D58675: [clang] Adds `-ftime-trace` option to clang that produces Chrome `chrome://tracing` compatible JSON profiling output dumps

Anton Afanasyev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 22 13:05:34 PDT 2019


anton-afanasyev marked 14 inline comments as done.
anton-afanasyev added inline comments.


================
Comment at: llvm/lib/IR/LegacyPassManager.cpp:1632-1634
+  bool profileTime = llvm::TimeTraceProfilerEnabled();
+  if (profileTime)
+    llvm::TimeTraceProfilerBegin("OptFunction", F.getName().data());
----------------
anton-afanasyev wrote:
> rnk wrote:
> > Someone is going to have to figure out where the equivalent annotations should live in the new passmanager. I wasn't able to find it just by looking myself, so I won't ask you to do it. I guess it's in llvm/include/llvm/IR/PassManager.h.
> Ok, I'm to look for it.
Looks like PassManager.h changing is enough to support new PassManager. But I prefer to make this change in subsequent commits.


================
Comment at: llvm/lib/IR/LegacyPassManager.cpp:1686
 
+  llvm::TimeTraceScope timeScope("OptModule", M.getName().data());
   for (Function &F : M)
----------------
rnk wrote:
> I think these OptModule and OptFunction labels may need some improvement. For a backend-heavy compilation like LLVM's X86ISelLowering.cpp, these labels aren't as good as they could be: {F8455962}
> I think it's fine to leave that for later, though.
Yes, leaving this for later. The subsequent commits are planned.


================
Comment at: llvm/lib/Support/TimeProfiler.cpp:70
+
+  void Begin(const std::string &name, const std::string &detail) {
+    Entry e = {steady_clock::now(), {}, name, detail};
----------------
rnk wrote:
> I'm tempted to micro-optimize this with StringRef and StringSaver, but I think it's unnecessary. Calling malloc may affect the profile, but probably not much.
Ok, I'm not changing this.


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

https://reviews.llvm.org/D58675





More information about the cfe-commits mailing list