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

Min-Yih Hsu via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 1 17:38:20 PDT 2024


https://github.com/mshockwave updated https://github.com/llvm/llvm-project/pull/106803

>From ead1c84ea93e6a7348139d400cdedec661099ab8 Mon Sep 17 00:00:00 2001
From: Min Hsu <min.hsu at sifive.com>
Date: Fri, 30 Aug 2024 14:36:57 -0700
Subject: [PATCH 1/2] [lld][ELF] Add `-plugin-opt=time-trace=` as an alias of
 `--time-trace=`

Time trace profiler support was added into LLVMgold in
cd3255abede5e3687c1538f2d3857deb2c51af1b. This patch adds its
`-plugin-opt` counterpart, which is just an alias to `--time-trace=`,
into LLD for compatibility.
---
 lld/ELF/Options.td             |  1 +
 lld/test/ELF/lto/time-trace.ll | 21 +++++++++++++++++++++
 2 files changed, 22 insertions(+)
 create mode 100644 lld/test/ELF/lto/time-trace.ll

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
+}
+

>From e6c813262c3ca1aaa12f3c88e38f3842a6446df4 Mon Sep 17 00:00:00 2001
From: Min Hsu <min at myhsu.dev>
Date: Sun, 1 Sep 2024 17:26:18 -0700
Subject: [PATCH 2/2] fixup! [lld][ELF] Add `-plugin-opt=time-trace=` as an
 alias of `--time-trace=`

---
 lld/test/ELF/lto/time-trace.ll | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/lld/test/ELF/lto/time-trace.ll b/lld/test/ELF/lto/time-trace.ll
index 405c0ad3a56988..0cd39037f60a24 100644
--- a/lld/test/ELF/lto/time-trace.ll
+++ b/lld/test/ELF/lto/time-trace.ll
@@ -1,9 +1,8 @@
 ; 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
+;; Print to stdout
 ; RUN: ld.lld -m elf_x86_64 -shared %t.o -o %t.so --plugin-opt=time-trace=- | \
 ; RUN: FileCheck %s
 
@@ -18,4 +17,3 @@ target triple = "x86_64-unknown-linux-gnu"
 define void @foo() {
   ret void
 }
-



More information about the llvm-commits mailing list