[llvm] [GlobalMerge][NFC] Fix inaccurate comment (PR #124136)

Michael Maitland via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 23 08:02:27 PST 2025


https://github.com/michaelmaitland created https://github.com/llvm/llvm-project/pull/124136

I was studying the code here and realized that the comments were talking about grouping by basic blocks when the code was grouping by Function. Fix the comments so they reflect what the code is actually doing.

>From af82b446f5aa31f7c406fc17a692f8814b6e6fe0 Mon Sep 17 00:00:00 2001
From: Michael Maitland <michaeltmaitland at gmail.com>
Date: Thu, 23 Jan 2025 07:53:08 -0800
Subject: [PATCH] [GlobalMerge][NFC] Fix inaccurate comment

I was studying the code here and realized that the comments were talking about
grouping by basic blocks when the code was grouping by Function. Fix the
comments so they reflect what the code is actually doing.
---
 llvm/lib/CodeGen/GlobalMerge.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/CodeGen/GlobalMerge.cpp b/llvm/lib/CodeGen/GlobalMerge.cpp
index 48d4d7848d84a7..1bc33183cad181 100644
--- a/llvm/lib/CodeGen/GlobalMerge.cpp
+++ b/llvm/lib/CodeGen/GlobalMerge.cpp
@@ -378,7 +378,7 @@ bool GlobalMergeImpl::doMerge(SmallVectorImpl<GlobalVariable *> &Globals,
 
         size_t UGSIdx = GlobalUsesByFunction[ParentFn];
 
-        // If this is the first global the basic block uses, map it to the set
+        // If this is the first global the function uses, map it to the set
         // consisting of this global only.
         if (!UGSIdx) {
           // If that set doesn't exist yet, create it.
@@ -393,7 +393,8 @@ bool GlobalMergeImpl::doMerge(SmallVectorImpl<GlobalVariable *> &Globals,
           continue;
         }
 
-        // If we already encountered this BB, just increment the counter.
+        // If we already encountered a use of this global in this function, just
+        // increment the counter.
         if (UsedGlobalSets[UGSIdx].Globals.test(GI)) {
           ++UsedGlobalSets[UGSIdx].UsageCount;
           continue;



More information about the llvm-commits mailing list