[llvm] [GlobalMerge] Fix inaccurate debug print. (PR #124377)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 24 16:53:51 PST 2025


https://github.com/topperc created https://github.com/llvm/llvm-project/pull/124377

This message was not updated when MinSize was added.

>From cf2d5ae0edc98be1c2132856c013bb97857dbb1d Mon Sep 17 00:00:00 2001
From: Craig Topper <craig.topper at sifive.com>
Date: Fri, 24 Jan 2025 16:52:30 -0800
Subject: [PATCH] [GlobalMerge] Fix inaccurate debug print.

This message was not updated when MinSize was added.
---
 llvm/lib/CodeGen/GlobalMerge.cpp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/llvm/lib/CodeGen/GlobalMerge.cpp b/llvm/lib/CodeGen/GlobalMerge.cpp
index 41e01a1d3ccd52..a22d9029239048 100644
--- a/llvm/lib/CodeGen/GlobalMerge.cpp
+++ b/llvm/lib/CodeGen/GlobalMerge.cpp
@@ -727,7 +727,8 @@ bool GlobalMergeImpl::run(Module &M) {
 
     Type *Ty = GV.getValueType();
     TypeSize AllocSize = DL.getTypeAllocSize(Ty);
-    if (AllocSize < Opt.MaxOffset && AllocSize >= Opt.MinSize) {
+    bool CanMerge = AllocSize < Opt.MaxOffset && AllocSize >= Opt.MinSize;
+    if (CanMerge) {
       if (TM &&
           TargetLoweringObjectFile::getKindForGlobal(&GV, *TM).isBSS())
         BSSGlobals[{AddressSpace, Section}].push_back(&GV);
@@ -737,9 +738,8 @@ bool GlobalMergeImpl::run(Module &M) {
         Globals[{AddressSpace, Section}].push_back(&GV);
     }
     LLVM_DEBUG(dbgs() << "GV "
-                      << ((DL.getTypeAllocSize(Ty) < Opt.MaxOffset)
-                              ? "to merge: "
-                              : "not to merge: ")
+                      << (CanMerge ? "" : "not ")
+                      << "to merge: "
                       << GV << "\n");
   }
 



More information about the llvm-commits mailing list