Skip to content

Commit 3afc2be

Browse files
authored
llvm-lto2: Add print-guid subcommand.
This is useful for debugging ThinLTO issues. Reviewers: teresajohnson Reviewed By: teresajohnson Pull Request: #143992
1 parent 8229628 commit 3afc2be

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# RUN: llvm-lto2 print-guid foo | FileCheck %s
2+
# CHECK: 6699318081062747564

llvm/tools/llvm-lto2/llvm-lto2.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ template <typename T> static T check(ErrorOr<T> E, std::string Msg) {
247247
}
248248

249249
static int usage() {
250-
errs() << "Available subcommands: dump-symtab run\n";
250+
errs() << "Available subcommands: dump-symtab run print-guid\n";
251251
return 1;
252252
}
253253

@@ -610,5 +610,11 @@ int main(int argc, char **argv) {
610610
return dumpSymtab(argc - 1, argv + 1);
611611
if (Subcommand == "run")
612612
return run(argc - 1, argv + 1);
613+
if (Subcommand == "print-guid" && argc > 2) {
614+
// Note the name of the function we're calling: this won't return the right
615+
// answer for internal linkage symbols.
616+
outs() << GlobalValue::getGUIDAssumingExternalLinkage(argv[2]) << '\n';
617+
return 0;
618+
}
613619
return usage();
614620
}

0 commit comments

Comments
 (0)