[llvm-branch-commits] [llvm] llvm-lto2: Add print-guid subcommand. (PR #143992)

2025-06-13 Thread Peter Collingbourne via llvm-branch-commits

pcc wrote:

> At least a comment in the code would be good. A variety of people end up 
> using these tools for tests, and I could see someone getting confused as to 
> why the guid doesn't match what's e.g. in the ThinLTO index. For that 
> understanding you'd have to read more than just what this source file is 
> calling.

I added a comment.

https://github.com/llvm/llvm-project/pull/143992
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] llvm-lto2: Add print-guid subcommand. (PR #143992)

2025-06-13 Thread Peter Collingbourne via llvm-branch-commits

https://github.com/pcc updated https://github.com/llvm/llvm-project/pull/143992

>From f11d7d544cc61dce582de538608bfd512147f90a Mon Sep 17 00:00:00 2001
From: Peter Collingbourne 
Date: Thu, 12 Jun 2025 16:06:14 -0700
Subject: [PATCH 1/2] Upload correct patch

Created using spr 1.3.6-beta.1
---
 llvm/tools/llvm-lto2/llvm-lto2.cpp | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/llvm/tools/llvm-lto2/llvm-lto2.cpp 
b/llvm/tools/llvm-lto2/llvm-lto2.cpp
index 5f5c954c6a57d..d35868ffafe1e 100644
--- a/llvm/tools/llvm-lto2/llvm-lto2.cpp
+++ b/llvm/tools/llvm-lto2/llvm-lto2.cpp
@@ -610,7 +610,9 @@ 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)
-outs() << GlobalValue::getGUIDAssumingExternalLinkage(argv[2]);
+  if (Subcommand == "print-guid" && argc > 2) {
+outs() << GlobalValue::getGUIDAssumingExternalLinkage(argv[2]) << '\n';
+return 0;
+  }
   return usage();
 }

>From c7cb16abb3c30e54a12ec1b9ce325d49cf37d2bc Mon Sep 17 00:00:00 2001
From: Peter Collingbourne 
Date: Fri, 13 Jun 2025 14:34:28 -0700
Subject: [PATCH 2/2] Add comment

Created using spr 1.3.6-beta.1
---
 llvm/tools/llvm-lto2/llvm-lto2.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/llvm/tools/llvm-lto2/llvm-lto2.cpp 
b/llvm/tools/llvm-lto2/llvm-lto2.cpp
index d35868ffafe1e..fbde6a596 100644
--- a/llvm/tools/llvm-lto2/llvm-lto2.cpp
+++ b/llvm/tools/llvm-lto2/llvm-lto2.cpp
@@ -611,6 +611,8 @@ int main(int argc, char **argv) {
   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;
   }

___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] llvm-lto2: Add print-guid subcommand. (PR #143992)

2025-06-13 Thread Teresa Johnson via llvm-branch-commits

https://github.com/teresajohnson approved this pull request.

lgtm otherwise

https://github.com/llvm/llvm-project/pull/143992
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] llvm-lto2: Add print-guid subcommand. (PR #143992)

2025-06-13 Thread Teresa Johnson via llvm-branch-commits

teresajohnson wrote:

> > This needs a caveat somewhere (either in printed usage message or in a 
> > comment) that this won't work for local linkage symbols (I suppose the user 
> > could give the "file:" prefix but that won't work if 
> > -funique-internal-linkage-names was specified etc).
> 
> I'm not sure that is worth it. The intent is that users of these development 
> tools will refer to the source code. And if you read the source code you'll 
> see the function name `getGUIDAssumingExternalLinkage` which tells you what 
> you need to know.

At least a comment in the code would be good. A variety of people end up using 
these tools for tests, and I could see someone getting confused as to why the 
guid doesn't match what's e.g. in the ThinLTO index. For that understanding 
you'd have to read more than just what this source file is calling.

https://github.com/llvm/llvm-project/pull/143992
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] llvm-lto2: Add print-guid subcommand. (PR #143992)

2025-06-13 Thread Peter Collingbourne via llvm-branch-commits

https://github.com/pcc updated https://github.com/llvm/llvm-project/pull/143992

>From f11d7d544cc61dce582de538608bfd512147f90a Mon Sep 17 00:00:00 2001
From: Peter Collingbourne 
Date: Thu, 12 Jun 2025 16:06:14 -0700
Subject: [PATCH] Upload correct patch

Created using spr 1.3.6-beta.1
---
 llvm/tools/llvm-lto2/llvm-lto2.cpp | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/llvm/tools/llvm-lto2/llvm-lto2.cpp 
b/llvm/tools/llvm-lto2/llvm-lto2.cpp
index 5f5c954c6a57d..d35868ffafe1e 100644
--- a/llvm/tools/llvm-lto2/llvm-lto2.cpp
+++ b/llvm/tools/llvm-lto2/llvm-lto2.cpp
@@ -610,7 +610,9 @@ 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)
-outs() << GlobalValue::getGUIDAssumingExternalLinkage(argv[2]);
+  if (Subcommand == "print-guid" && argc > 2) {
+outs() << GlobalValue::getGUIDAssumingExternalLinkage(argv[2]) << '\n';
+return 0;
+  }
   return usage();
 }

___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] llvm-lto2: Add print-guid subcommand. (PR #143992)

2025-06-13 Thread Peter Collingbourne via llvm-branch-commits

https://github.com/pcc updated https://github.com/llvm/llvm-project/pull/143992

>From f11d7d544cc61dce582de538608bfd512147f90a Mon Sep 17 00:00:00 2001
From: Peter Collingbourne 
Date: Thu, 12 Jun 2025 16:06:14 -0700
Subject: [PATCH] Upload correct patch

Created using spr 1.3.6-beta.1
---
 llvm/tools/llvm-lto2/llvm-lto2.cpp | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/llvm/tools/llvm-lto2/llvm-lto2.cpp 
b/llvm/tools/llvm-lto2/llvm-lto2.cpp
index 5f5c954c6a57d..d35868ffafe1e 100644
--- a/llvm/tools/llvm-lto2/llvm-lto2.cpp
+++ b/llvm/tools/llvm-lto2/llvm-lto2.cpp
@@ -610,7 +610,9 @@ 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)
-outs() << GlobalValue::getGUIDAssumingExternalLinkage(argv[2]);
+  if (Subcommand == "print-guid" && argc > 2) {
+outs() << GlobalValue::getGUIDAssumingExternalLinkage(argv[2]) << '\n';
+return 0;
+  }
   return usage();
 }

___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] llvm-lto2: Add print-guid subcommand. (PR #143992)

2025-06-13 Thread Peter Collingbourne via llvm-branch-commits

pcc wrote:

> This needs a caveat somewhere (either in printed usage message or in a 
> comment) that this won't work for local linkage symbols (I suppose the user 
> could give the "file:" prefix but that won't work if 
> -funique-internal-linkage-names was specified etc).

I'm not sure that is worth it. The intent is that users of these development 
tools will refer to the source code. And if you read the source code you'll see 
the function name `getGUIDAssumingExternalLinkage` which tells you what you 
need to know.

> Can you also add a test?

Done.

https://github.com/llvm/llvm-project/pull/143992
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] llvm-lto2: Add print-guid subcommand. (PR #143992)

2025-06-13 Thread Teresa Johnson via llvm-branch-commits

https://github.com/teresajohnson commented:

This needs a caveat somewhere (either in printed usage message or in a comment) 
that this won't work for local linkage symbols (I suppose the user could give 
the "file:" prefix but that won't work if -funique-internal-linkage-names was 
specified etc). Can you also add a test?

https://github.com/llvm/llvm-project/pull/143992
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] llvm-lto2: Add print-guid subcommand. (PR #143992)

2025-06-12 Thread Peter Collingbourne via llvm-branch-commits

https://github.com/pcc updated https://github.com/llvm/llvm-project/pull/143992

>From f11d7d544cc61dce582de538608bfd512147f90a Mon Sep 17 00:00:00 2001
From: Peter Collingbourne 
Date: Thu, 12 Jun 2025 16:06:14 -0700
Subject: [PATCH] Upload correct patch

Created using spr 1.3.6-beta.1
---
 llvm/tools/llvm-lto2/llvm-lto2.cpp | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/llvm/tools/llvm-lto2/llvm-lto2.cpp 
b/llvm/tools/llvm-lto2/llvm-lto2.cpp
index 5f5c954c6a57d..d35868ffafe1e 100644
--- a/llvm/tools/llvm-lto2/llvm-lto2.cpp
+++ b/llvm/tools/llvm-lto2/llvm-lto2.cpp
@@ -610,7 +610,9 @@ 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)
-outs() << GlobalValue::getGUIDAssumingExternalLinkage(argv[2]);
+  if (Subcommand == "print-guid" && argc > 2) {
+outs() << GlobalValue::getGUIDAssumingExternalLinkage(argv[2]) << '\n';
+return 0;
+  }
   return usage();
 }

___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits