[PATCH] D128046: Add a new clang option "-ftime-trace-path"

dongjunduo via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 17 05:45:55 PDT 2022


dongjunduo created this revision.
Herald added a project: All.
dongjunduo requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Add a new clang option "-ftime-trace-path".

The time profiler traces the stages during the clang compile 
process. Each compiling stage of a single source file 
corresponds to a separately .json file which holds its 
time tracing data. However, the .json files are stored in the 
same path/directory as its corresponding stage's '-o' option.
For example, if we compile the "demo.cc" to "demo.o" with option
"-o /tmp/demo.o", the time trace data file path is "/tmp/demo.json".

A typical c++ project can contain multiple source files in different 
path, but all the json files' paths can be a mess.

The option "-ftime-trace-path" allows you to specify where the json 
files should be stored. This allows the users to place the time trace 
data files of interest in the desired location for further data analysis.

Usage:

  clang/clang++ -ftime-trace -ftime-trace-path=/path-you-want/ ...


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128046

Files:
  clang/tools/driver/cc1_main.cpp


Index: clang/tools/driver/cc1_main.cpp
===================================================================
--- clang/tools/driver/cc1_main.cpp
+++ clang/tools/driver/cc1_main.cpp
@@ -255,8 +255,7 @@
 
   if (llvm::timeTraceProfilerEnabled()) {
     SmallString<128> Path(Clang->getFrontendOpts().TimeTracePath);
-    Path.append(llvm::sys::path::filename(
-        Clang->getFrontendOpts().OutputFile));
+    Path.append(llvm::sys::path::filename(Clang->getFrontendOpts().OutputFile));
     Path.append(".json");
     if (auto profilerOutput = Clang->createOutputFile(
             Path.str(), /*Binary=*/false, /*RemoveFileOnSignal=*/false,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128046.437862.patch
Type: text/x-patch
Size: 642 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220617/aed715e3/attachment-0001.bin>


More information about the cfe-commits mailing list