Skip to content

[Support][LLD] .time-trace.json Default File Extension #122207

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lld/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion lld/test/COFF/time-trace.s
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions lld/test/ELF/lto/thinlto-time-trace.ll
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lld/test/ELF/time-trace.s
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lld/test/MachO/map-file.s
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lld/test/MachO/thinlto-time-trace.ll
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lld/test/MachO/time-trace.s
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 3 additions & 1 deletion llvm/include/llvm/Support/TimeProfiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Support/TimeProfiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading