Skip to content

[lld][ELF] Add -plugin-opt=time-trace= as an alias of --time-trace= #106803

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

Merged
merged 2 commits into from
Sep 2, 2024

Conversation

mshockwave
Copy link
Member

Time trace profiler support was added into LLVMgold in cd3255a. This patch adds its -plugin-opt counterpart, which is just an alias to --time-trace=, into LLD for compatibility.

Time trace profiler support was added into LLVMgold in
cd3255a. This patch adds its
`-plugin-opt` counterpart, which is just an alias to `--time-trace=`,
into LLD for compatibility.
@llvmbot
Copy link
Member

llvmbot commented Aug 30, 2024

@llvm/pr-subscribers-lld-elf

@llvm/pr-subscribers-lld

Author: Min-Yih Hsu (mshockwave)

Changes

Time trace profiler support was added into LLVMgold in cd3255a. This patch adds its -plugin-opt counterpart, which is just an alias to --time-trace=, into LLD for compatibility.


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

2 Files Affected:

  • (modified) lld/ELF/Options.td (+1)
  • (added) lld/test/ELF/lto/time-trace.ll (+21)
diff --git a/lld/ELF/Options.td b/lld/ELF/Options.td
index 74733efb28ff5e..c80c4017d3512c 100644
--- a/lld/ELF/Options.td
+++ b/lld/ELF/Options.td
@@ -729,6 +729,7 @@ def: J<"plugin-opt=sample-profile=">,
 def: F<"plugin-opt=save-temps">, Alias<save_temps>, HelpText<"Alias for --save-temps">;
 def plugin_opt_stats_file: J<"plugin-opt=stats-file=">,
   HelpText<"Filename to write LTO statistics to">;
+def: J<"plugin-opt=time-trace=">, Alias<time_trace_eq>, HelpText<"Alias for --time-trace=">;
 def: F<"plugin-opt=thinlto-emit-imports-files">,
   Alias<thinlto_emit_imports_files>,
   HelpText<"Alias for --thinlto-emit-imports-files">;
diff --git a/lld/test/ELF/lto/time-trace.ll b/lld/test/ELF/lto/time-trace.ll
new file mode 100644
index 00000000000000..405c0ad3a56988
--- /dev/null
+++ b/lld/test/ELF/lto/time-trace.ll
@@ -0,0 +1,21 @@
+; REQUIRES: x86
+; RUN: llvm-as %s -o %t.o
+; Print to a specific file
+; RUN: ld.lld -m elf_x86_64 -shared %t.o -o %t.so --plugin-opt=time-trace=%t.trace.json
+; RUN: FileCheck --input-file=%t.trace.json %s
+; Print to stdout
+; RUN: ld.lld -m elf_x86_64 -shared %t.o -o %t.so --plugin-opt=time-trace=- | \
+; RUN: FileCheck %s
+
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+; Make sure the content is correct
+; CHECK: "traceEvents"
+; Make sure LTO events are recorded
+; CHECK-SAME: "name":"LTO"
+
+define void @foo() {
+  ret void
+}
+

@@ -0,0 +1,21 @@
; REQUIRES: x86
; RUN: llvm-as %s -o %t.o
; Print to a specific file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The command self explains and the comment is not that useful

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

; Print to a specific file
; RUN: ld.lld -m elf_x86_64 -shared %t.o -o %t.so --plugin-opt=time-trace=%t.trace.json
; RUN: FileCheck --input-file=%t.trace.json %s
; Print to stdout
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the comment is to be kept, ;;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

define void @foo() {
ret void
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no trailing blank lines

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@mshockwave mshockwave merged commit 5fe852e into llvm:main Sep 2, 2024
5 of 8 checks passed
@mshockwave mshockwave deleted the patch/lld-plugin-opt-time-trace branch September 2, 2024 00:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants