[lld] [llvm] [Support][LLD] .time-trace.json Default File Extension (PR #122207)

via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 8 18:34:07 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lld-macho

Author: Miguel A. Arroyo (mayanez)

<details>
<summary>Changes</summary>

* Addresses the LLD portion of https://github.com/llvm/llvm-project/issues/96339
* Changes the default file extension in `lld` from `.time-trace` to `.time-trace.json`.
  * As mentioned in the issue, another option worth considering is `.lld.time-trace.json` though I've refrained from doing so in this PR to keep changes minimal.

---
Full diff: https://github.com/llvm/llvm-project/pull/122207.diff


9 Files Affected:

- (modified) lld/docs/ReleaseNotes.rst (+2) 
- (modified) lld/test/COFF/time-trace.s (+1-1) 
- (modified) lld/test/ELF/lto/thinlto-time-trace.ll (+2-2) 
- (modified) lld/test/ELF/time-trace.s (+1-1) 
- (modified) lld/test/MachO/map-file.s (+1-1) 
- (modified) lld/test/MachO/thinlto-time-trace.ll (+1-1) 
- (modified) lld/test/MachO/time-trace.s (+1-1) 
- (modified) llvm/include/llvm/Support/TimeProfiler.h (+3-1) 
- (modified) llvm/lib/Support/TimeProfiler.cpp (+1-1) 


``````````diff
diff --git a/lld/docs/ReleaseNotes.rst b/lld/docs/ReleaseNotes.rst
index 0c24156ae16799..966bb40027bafd 100644
--- a/lld/docs/ReleaseNotes.rst
+++ b/lld/docs/ReleaseNotes.rst
@@ -48,6 +48,8 @@ Breaking changes
   was a binutils-internal relocation used during relaxation, and was not
   emitted by compilers/assemblers.
 
+* The default extension for time trace files is now ``.time-trace.json``.
+
 COFF Improvements
 -----------------
 * ``/includeglob`` has been implemented to match the behavior of ``--undefined-glob`` available for ELF.
diff --git a/lld/test/COFF/time-trace.s b/lld/test/COFF/time-trace.s
index 436da2483a54f6..8a03abdbbf3696 100644
--- a/lld/test/COFF/time-trace.s
+++ b/lld/test/COFF/time-trace.s
@@ -4,7 +4,7 @@
 
 # Test implicit trace file name
 # RUN: lld-link %t.obj /entry:main /out:%t1.exe --time-trace --time-trace-granularity=0
-# RUN: cat %t1.exe.time-trace \
+# RUN: cat %t1.exe.time-trace.json \
 # 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/ELF/lto/thinlto-time-trace.ll b/lld/test/ELF/lto/thinlto-time-trace.ll
index 2213a3051f52be..76d54be3dc7b45 100644
--- a/lld/test/ELF/lto/thinlto-time-trace.ll
+++ b/lld/test/ELF/lto/thinlto-time-trace.ll
@@ -6,13 +6,13 @@
 
 ; Test single-threaded
 ; RUN: ld.lld --thinlto-jobs=1 --time-trace --time-trace-granularity=0 -shared %t1.o %t2.o -o %t3.so
-; RUN: cat %t3.so.time-trace \
+; RUN: cat %t3.so.time-trace.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 multi-threaded
 ; RUN: ld.lld --time-trace --time-trace-granularity=0 -shared %t1.o %t2.o -o %t4.so
-; RUN: cat %t4.so.time-trace \
+; RUN: cat %t4.so.time-trace.json \
 ; 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/ELF/time-trace.s b/lld/test/ELF/time-trace.s
index 0a2e76e936b95d..74ef567b2b17de 100644
--- a/lld/test/ELF/time-trace.s
+++ b/lld/test/ELF/time-trace.s
@@ -3,7 +3,7 @@
 
 # Test implicit trace file name
 # RUN: ld.lld --time-trace --time-trace-granularity=0 -o %t1.elf %t.o
-# RUN: cat %t1.elf.time-trace \
+# RUN: cat %t1.elf.time-trace.json \
 # 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/map-file.s b/lld/test/MachO/map-file.s
index aa9fff9938eb28..1c1ba5a4a2d565 100644
--- a/lld/test/MachO/map-file.s
+++ b/lld/test/MachO/map-file.s
@@ -15,7 +15,7 @@
 ## Also check that we don't have redundant EH_Frame symbols (regression test)
 # RUN: cat %t/objdump %t/map | FileCheck %s --implicit-check-not _hello_world \
 # RUN:   --implicit-check-not EH_Frame
-# RUN: FileCheck %s --check-prefix=MAPFILE < %t/test.time-trace
+# RUN: FileCheck %s --check-prefix=MAPFILE < %t/test.time-trace.json
 
 # CHECK:       Sections:
 # CHECK-NEXT:  Idx  Name         Size     VMA               Type
diff --git a/lld/test/MachO/thinlto-time-trace.ll b/lld/test/MachO/thinlto-time-trace.ll
index de2116fa47f2bc..14c697aebf51d1 100644
--- a/lld/test/MachO/thinlto-time-trace.ll
+++ b/lld/test/MachO/thinlto-time-trace.ll
@@ -5,7 +5,7 @@
 ; RUN: opt -module-summary %t/f.s -o %t/f.o
 ; RUN: opt -module-summary %t/g.s -o %t/g.o
 ; RUN: %lld --time-trace --time-trace-granularity=0 -dylib %t/f.o %t/g.o -o %t/libTest.dylib
-; RUN: cat %t/libTest.dylib.time-trace \
+; RUN: cat %t/libTest.dylib.time-trace.json \
 ; 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 aa21bf8a1a4289..c113421cd781bf 100644
--- a/lld/test/MachO/time-trace.s
+++ b/lld/test/MachO/time-trace.s
@@ -7,7 +7,7 @@
 
 ## Test implicit trace file name
 # RUN: %lld --time-trace --time-trace-granularity=0 -o %t1.macho %t.o
-# RUN: cat %t1.macho.time-trace \
+# RUN: cat %t1.macho.time-trace.json \
 # 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/llvm/include/llvm/Support/TimeProfiler.h b/llvm/include/llvm/Support/TimeProfiler.h
index 679e157f3dfd82..04f8ae8e8e2939 100644
--- a/llvm/include/llvm/Support/TimeProfiler.h
+++ b/llvm/include/llvm/Support/TimeProfiler.h
@@ -83,6 +83,8 @@ namespace llvm {
 
 class raw_pwrite_stream;
 
+static constexpr const auto TimeTraceFileExtension = ".time-trace.json";
+
 // Type of the time trace event.
 enum class TimeTraceEventType {
   // Complete events have a duration (start and end time points) and are marked
@@ -137,7 +139,7 @@ void timeTraceProfilerWrite(raw_pwrite_stream &OS);
 
 /// Write profiling data to a file.
 /// The function will write to \p PreferredFileName if provided, if not
-/// then will write to \p FallbackFileName appending .time-trace.
+/// then will write to \p FallbackFileName appending .time-trace.json.
 /// Returns a StringError indicating a failure if the function is
 /// unable to open the file for writing.
 Error timeTraceProfilerWrite(StringRef PreferredFileName,
diff --git a/llvm/lib/Support/TimeProfiler.cpp b/llvm/lib/Support/TimeProfiler.cpp
index 865a663115e1ed..d14da3ea2942d6 100644
--- a/llvm/lib/Support/TimeProfiler.cpp
+++ b/llvm/lib/Support/TimeProfiler.cpp
@@ -434,7 +434,7 @@ Error llvm::timeTraceProfilerWrite(StringRef PreferredFileName,
   std::string Path = PreferredFileName.str();
   if (Path.empty()) {
     Path = FallbackFileName == "-" ? "out" : FallbackFileName.str();
-    Path += ".time-trace";
+    Path += TimeTraceFileExtension;
   }
 
   std::error_code EC;

``````````

</details>


https://github.com/llvm/llvm-project/pull/122207


More information about the llvm-commits mailing list