From cf2d5ae0edc98be1c2132856c013bb97857dbb1d Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Fri, 24 Jan 2025 16:52:30 -0800 Subject: [PATCH 1/2] [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 41e01a1d3ccd5..a22d902923904 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"); } From ebba9d2f8b0640aa70f58edaed201f2196a3d7ce Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Fri, 24 Jan 2025 17:41:39 -0800 Subject: [PATCH 2/2] fixup! clang-format --- llvm/lib/CodeGen/GlobalMerge.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/llvm/lib/CodeGen/GlobalMerge.cpp b/llvm/lib/CodeGen/GlobalMerge.cpp index a22d902923904..6ddc145bd90bb 100644 --- a/llvm/lib/CodeGen/GlobalMerge.cpp +++ b/llvm/lib/CodeGen/GlobalMerge.cpp @@ -737,10 +737,8 @@ bool GlobalMergeImpl::run(Module &M) { else Globals[{AddressSpace, Section}].push_back(&GV); } - LLVM_DEBUG(dbgs() << "GV " - << (CanMerge ? "" : "not ") - << "to merge: " - << GV << "\n"); + LLVM_DEBUG(dbgs() << "GV " << (CanMerge ? "" : "not ") << "to merge: " << GV + << "\n"); } for (auto &P : Globals)