[llvm] [AsmPrinter] Always emit global equivalents if there is non-global uses (PR #145648)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 25 00:36:48 PDT 2025


================
@@ -2142,16 +2144,20 @@ void AsmPrinter::emitFunctionBody() {
 }
 
 /// Compute the number of Global Variables that uses a Constant.
-static unsigned getNumGlobalVariableUses(const Constant *C) {
-  if (!C)
+static unsigned getNumGlobalVariableUses(const Constant *C,
+                                         bool &HasNonGlobalUsers) {
+  if (!C) {
+    HasNonGlobalUsers = true;
     return 0;
+  }
----------------
arsenm wrote:

I'd directly handle the case where the dyn_cast failed in the users loop instead of adding this out argument 

https://github.com/llvm/llvm-project/pull/145648


More information about the llvm-commits mailing list