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
This commit is contained in:
Peter Collingbourne 2025-06-13 14:35:40 -07:00 committed by GitHub
parent 8229628cf1
commit 3afc2be1f0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 1 deletions

View File

@ -0,0 +1,2 @@
# RUN: llvm-lto2 print-guid foo | FileCheck %s
# CHECK: 6699318081062747564

View File

@ -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();
}