[llvm] [llvm-lto2] Added llvm-lto2 -unified-lto descriptions (PR #148309)

Faith Rivera via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 14 10:44:05 PDT 2025


https://github.com/fnriv updated https://github.com/llvm/llvm-project/pull/148309

>From 44efd4d8a8cc5aa8c260b7103f36fa55000989bf Mon Sep 17 00:00:00 2001
From: Faith Rivera <103224896+fnriv at users.noreply.github.com>
Date: Thu, 10 Jul 2025 13:45:57 -0700
Subject: [PATCH 1/2] Add -unified-lto flag mode descriptions

---
 llvm/tools/llvm-lto2/llvm-lto2.cpp | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/llvm/tools/llvm-lto2/llvm-lto2.cpp b/llvm/tools/llvm-lto2/llvm-lto2.cpp
index fbde66666a596..1f61dfec918b5 100644
--- a/llvm/tools/llvm-lto2/llvm-lto2.cpp
+++ b/llvm/tools/llvm-lto2/llvm-lto2.cpp
@@ -198,9 +198,13 @@ static cl::list<std::string>
     PassPlugins("load-pass-plugin",
                 cl::desc("Load passes from plugin library"));
 
-static cl::opt<std::string> UnifiedLTOMode("unified-lto", cl::Optional,
-                                           cl::desc("Set LTO mode"),
-                                           cl::value_desc("mode"));
+static cl::opt<std::string> UnifiedLTOMode(
+    "unified-lto", cl::Optional,
+    cl::desc("Set LTO mode with the following options:\n"
+             " thin      ThinLTO, with Unified LTO enabled.\n"
+             " full      Regular LTO, with Unified LTO enabled.\n"
+             " default   Any LTO mode without Unified LTO. The default mode."),
+    cl::value_desc("mode"));
 
 static cl::opt<bool> EnableFreestanding(
     "lto-freestanding",

>From 0e9cd60ccc726da6487098befe2a1e6aabc236f5 Mon Sep 17 00:00:00 2001
From: Faith Rivera <103224896+fnriv at users.noreply.github.com>
Date: Mon, 14 Jul 2025 10:43:09 -0700
Subject: [PATCH 2/2] Added llvm-lto2 version command

---
 llvm/test/tools/llvm-lto2/version.test | 7 +++++++
 llvm/tools/llvm-lto2/llvm-lto2.cpp     | 7 ++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)
 create mode 100644 llvm/test/tools/llvm-lto2/version.test

diff --git a/llvm/test/tools/llvm-lto2/version.test b/llvm/test/tools/llvm-lto2/version.test
new file mode 100644
index 0000000000000..87ac738ab5da2
--- /dev/null
+++ b/llvm/test/tools/llvm-lto2/version.test
@@ -0,0 +1,7 @@
+## Show that you can run version as a main command for llvm-lto2 
+## or a subcommand of llvm-lto2 run.
+
+RUN: llvm-lto2 version | Filecheck %s
+RUN: llvm-lto2 run --version | FileCheck %s 
+
+CHECK: version
diff --git a/llvm/tools/llvm-lto2/llvm-lto2.cpp b/llvm/tools/llvm-lto2/llvm-lto2.cpp
index 1f61dfec918b5..0cbb100372fe0 100644
--- a/llvm/tools/llvm-lto2/llvm-lto2.cpp
+++ b/llvm/tools/llvm-lto2/llvm-lto2.cpp
@@ -251,7 +251,7 @@ template <typename T> static T check(ErrorOr<T> E, std::string Msg) {
 }
 
 static int usage() {
-  errs() << "Available subcommands: dump-symtab run print-guid\n";
+  errs() << "Available subcommands: dump-symtab run print-guid version\n";
   return 1;
 }
 
@@ -620,5 +620,10 @@ int main(int argc, char **argv) {
     outs() << GlobalValue::getGUIDAssumingExternalLinkage(argv[2]) << '\n';
     return 0;
   }
+  if (Subcommand == "version") {
+    cl::PrintVersionMessage();
+    return 0;
+  }
+
   return usage();
 }



More information about the llvm-commits mailing list