[llvm] 3afc2be - llvm-lto2: Add print-guid subcommand.
via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 13 14:35:44 PDT 2025
Author: Peter Collingbourne
Date: 2025-06-13T14:35:40-07:00
New Revision: 3afc2be1f0a4d3e3f646403a7495bcb12ef94246
URL: https://github.com/llvm/llvm-project/commit/3afc2be1f0a4d3e3f646403a7495bcb12ef94246
DIFF: https://github.com/llvm/llvm-project/commit/3afc2be1f0a4d3e3f646403a7495bcb12ef94246.diff
LOG: llvm-lto2: Add print-guid subcommand.
This is useful for debugging ThinLTO issues.
Reviewers: teresajohnson
Reviewed By: teresajohnson
Pull Request: https://github.com/llvm/llvm-project/pull/143992
Added:
llvm/test/tools/llvm-lto2/print-guid.test
Modified:
llvm/tools/llvm-lto2/llvm-lto2.cpp
Removed:
################################################################################
diff --git a/llvm/test/tools/llvm-lto2/print-guid.test b/llvm/test/tools/llvm-lto2/print-guid.test
new file mode 100644
index 0000000000000..a3d3f202ea437
--- /dev/null
+++ b/llvm/test/tools/llvm-lto2/print-guid.test
@@ -0,0 +1,2 @@
+# RUN: llvm-lto2 print-guid foo | FileCheck %s
+# CHECK: 6699318081062747564
diff --git a/llvm/tools/llvm-lto2/llvm-lto2.cpp b/llvm/tools/llvm-lto2/llvm-lto2.cpp
index 2bbb65be3b31e..fbde66666a596 100644
--- a/llvm/tools/llvm-lto2/llvm-lto2.cpp
+++ b/llvm/tools/llvm-lto2/llvm-lto2.cpp
@@ -247,7 +247,7 @@ template <typename T> static T check(ErrorOr<T> E, std::string Msg) {
}
static int usage() {
- errs() << "Available subcommands: dump-symtab run\n";
+ errs() << "Available subcommands: dump-symtab run print-guid\n";
return 1;
}
@@ -610,5 +610,11 @@ int main(int argc, char **argv) {
return dumpSymtab(argc - 1, argv + 1);
if (Subcommand == "run")
return run(argc - 1, argv + 1);
+ if (Subcommand == "print-guid" && argc > 2) {
+ // Note the name of the function we're calling: this won't return the right
+ // answer for internal linkage symbols.
+ outs() << GlobalValue::getGUIDAssumingExternalLinkage(argv[2]) << '\n';
+ return 0;
+ }
return usage();
}
More information about the llvm-commits
mailing list