[lld] a2c1f7c - [lld, ELF and mac] Add --time-trace=<file>, remove --time-trace-file=<file>

Nico Weber via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 23 12:48:46 PDT 2022


Author: Nico Weber
Date: 2022-06-23T15:46:22-04:00
New Revision: a2c1f7c90da770167cecdb008fcf40eaa9f123ce

URL: https://github.com/llvm/llvm-project/commit/a2c1f7c90da770167cecdb008fcf40eaa9f123ce
DIFF: https://github.com/llvm/llvm-project/commit/a2c1f7c90da770167cecdb008fcf40eaa9f123ce.diff

LOG: [lld, ELF and mac] Add --time-trace=<file>, remove --time-trace-file=<file>

`--time-trace=foo` has the same behavior as `--time-trace --time-trace-file=<file>`
had previously.

Also, for mac, make --time-trace-granularity *not* imply --time-trace, to match
behavior of the ELF port.

Differential Revision: https://reviews.llvm.org/D128451

Added: 
    

Modified: 
    lld/ELF/Driver.cpp
    lld/ELF/Options.td
    lld/MachO/Driver.cpp
    lld/MachO/Options.td
    lld/docs/ReleaseNotes.rst
    lld/test/ELF/time-trace.s
    lld/test/MachO/time-trace.s

Removed: 
    


################################################################################
diff  --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index e5b7e84986971..8315d43c776e8 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -593,8 +593,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
 
   if (config->timeTraceEnabled) {
     checkError(timeTraceProfilerWrite(
-        args.getLastArgValue(OPT_time_trace_file_eq).str(),
-        config->outputFile));
+        args.getLastArgValue(OPT_time_trace_eq).str(), config->outputFile));
     timeTraceProfilerCleanup();
   }
 }
@@ -1195,7 +1194,7 @@ static void readConfigs(opt::InputArgList &args) {
   }
   config->thinLTOModulesToCompile =
       args::getStrings(args, OPT_thinlto_single_module_eq);
-  config->timeTraceEnabled = args.hasArg(OPT_time_trace);
+  config->timeTraceEnabled = args.hasArg(OPT_time_trace_eq);
   config->timeTraceGranularity =
       args::getInteger(args, OPT_time_trace_granularity, 500);
   config->trace = args.hasArg(OPT_trace);

diff  --git a/lld/ELF/Options.td b/lld/ELF/Options.td
index f6483870d2a9e..f4c522c267b9b 100644
--- a/lld/ELF/Options.td
+++ b/lld/ELF/Options.td
@@ -408,8 +408,10 @@ defm threads
          "Number of threads. '1' disables multi-threading. By default all "
          "available hardware threads are used">;
 
-def time_trace: FF<"time-trace">, HelpText<"Record time trace">;
-def time_trace_file_eq: JJ<"time-trace-file=">, HelpText<"Specify time trace output file">;
+def time_trace_eq: JJ<"time-trace=">, MetaVarName<"<file>">,
+  HelpText<"Record time trace to <file>">;
+def : FF<"time-trace">, Alias<time_trace_eq>,
+  HelpText<"Record time trace to file next to output">;
 
 defm time_trace_granularity: EEq<"time-trace-granularity",
   "Minimum time granularity (in microseconds) traced by time profiler">;

diff  --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp
index 2518f83602eb5..badab058c84aa 100644
--- a/lld/MachO/Driver.cpp
+++ b/lld/MachO/Driver.cpp
@@ -1494,8 +1494,7 @@ bool macho::link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
 
   config->progName = argsArr[0];
 
-  config->timeTraceEnabled = args.hasArg(
-      OPT_time_trace, OPT_time_trace_granularity_eq, OPT_time_trace_file_eq);
+  config->timeTraceEnabled = args.hasArg(OPT_time_trace_eq);
   config->timeTraceGranularity =
       args::getInteger(args, OPT_time_trace_granularity_eq, 500);
 
@@ -1631,8 +1630,7 @@ bool macho::link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
 
   if (config->timeTraceEnabled) {
     checkError(timeTraceProfilerWrite(
-        args.getLastArgValue(OPT_time_trace_file_eq).str(),
-        config->outputFile));
+        args.getLastArgValue(OPT_time_trace_eq).str(), config->outputFile));
 
     timeTraceProfilerCleanup();
   }

diff  --git a/lld/MachO/Options.td b/lld/MachO/Options.td
index b4092c7ec80aa..c3ccbec6c997b 100644
--- a/lld/MachO/Options.td
+++ b/lld/MachO/Options.td
@@ -43,14 +43,17 @@ def version: Flag<["--"], "version">,
 def no_lto_legacy_pass_manager : Flag<["--"], "no-lto-legacy-pass-manager">,
     HelpText<"Use the new pass manager in LLVM">,
     Group<grp_lld>;
-def time_trace: Flag<["--"], "time-trace">, HelpText<"Record time trace">,
+def time_trace_eq: Joined<["--"], "time-trace=">,
+    HelpText<"Record time trace to <file>">,
+    MetaVarName<"<file>">,
+    Group<grp_lld>;
+def : Flag<["--"], "time-trace">,
+    Alias<time_trace_eq>,
+    HelpText<"Record time trace to file next to output">,
     Group<grp_lld>;
 def time_trace_granularity_eq: Joined<["--"], "time-trace-granularity=">,
     HelpText<"Minimum time granularity (in microseconds) traced by time profiler">,
     Group<grp_lld>;
-def time_trace_file_eq: Joined<["--"], "time-trace-file=">,
-    HelpText<"Specify time trace output file">,
-    Group<grp_lld>;
 def deduplicate_literals: Flag<["--"], "deduplicate-literals">,
     HelpText<"Enable literal deduplication. This is implied by --icf={safe,all}">,
     Group<grp_lld>;

diff  --git a/lld/docs/ReleaseNotes.rst b/lld/docs/ReleaseNotes.rst
index 99d875a7ed5d7..527ab4fead382 100644
--- a/lld/docs/ReleaseNotes.rst
+++ b/lld/docs/ReleaseNotes.rst
@@ -41,6 +41,9 @@ Breaking changes
 * Support for the legacy ``.zdebug`` format has been removed. Run
   ``objcopy --decompress-debug-sections`` in case old object files use ``.zdebug``.
   (`D126793 <https://reviews.llvm.org/D126793>`_)
+* ``--time-trace-file=<file>`` has been removed.
+  Use ``--time-trace=<file>`` instead.
+  (`D128451 <https://reviews.llvm.org/D128451>`_)
 
 COFF Improvements
 -----------------

diff  --git a/lld/test/ELF/time-trace.s b/lld/test/ELF/time-trace.s
index f7c18dff92fd6..0a2e76e936b95 100644
--- a/lld/test/ELF/time-trace.s
+++ b/lld/test/ELF/time-trace.s
@@ -8,13 +8,13 @@
 # RUN:   | FileCheck %s
 
 # Test specified trace file name
-# RUN: ld.lld --time-trace --time-trace-file=%t2.json --time-trace-granularity=0 -o %t2.elf %t.o
+# RUN: ld.lld --time-trace=%t2.json --time-trace-granularity=0 -o %t2.elf %t.o
 # RUN: cat %t2.json \
 # RUN:   | %python -c 'import json, sys; json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
 # RUN:   | FileCheck %s
 
 # Test trace requested to stdout
-# RUN: ld.lld --time-trace --time-trace-file=- --time-trace-granularity=0 -o %t3.elf %t.o \
+# RUN: ld.lld --time-trace=- --time-trace-granularity=0 -o %t3.elf %t.o \
 # RUN:   | %python -c 'import json, sys; json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
 # RUN:   | FileCheck %s
 

diff  --git a/lld/test/MachO/time-trace.s b/lld/test/MachO/time-trace.s
index e75bcd2722993..aa21bf8a1a428 100644
--- a/lld/test/MachO/time-trace.s
+++ b/lld/test/MachO/time-trace.s
@@ -11,14 +11,14 @@
 # RUN:   | %python -c 'import json, sys; json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
 # RUN:   | FileCheck %s
 
-## Test specified trace file name, also test that `--time-trace` is not needed if the other two are used.
-# RUN: %lld --time-trace-file=%t2.json --time-trace-granularity=0 -o %t2.macho %t.o
+## Test specified trace file name.
+# RUN: %lld --time-trace=%t2.json --time-trace-granularity=0 -o %t2.macho %t.o
 # RUN: cat %t2.json \
 # RUN:   | %python -c 'import json, sys; json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
 # RUN:   | FileCheck %s
 
-## Test trace requested to stdout, also test that `--time-trace` is not needed if the other two are used.
-# RUN: %lld --time-trace-file=- --time-trace-granularity=0 -o %t3.macho %t.o \
+## Test trace requested to stdout.
+# RUN: %lld --time-trace=- --time-trace-granularity=0 -o %t3.macho %t.o \
 # RUN:   | %python -c 'import json, sys; json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
 # RUN:   | FileCheck %s
 


        


More information about the llvm-commits mailing list