[llvm] [ICP] Use a block with LLVM_DEBUG (NFC) (PR #140387)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sat May 17 10:47:53 PDT 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/140387
Using a block inside LLVM_DEBUG allows us to simplify the code with a
single LLVM_DEBUG and remove maybe_unused.
>From 2050ad4e68bb0a8240395a8fe8c471e82279f5f7 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sat, 17 May 2025 10:37:39 -0700
Subject: [PATCH] [ICP] Use a block with LLVM_DEBUG (NFC)
Using a block inside LLVM_DEBUG allows us to simplify the code with a
single LLVM_DEBUG and remove maybe_unused.
---
.../Instrumentation/IndirectCallPromotion.cpp | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp b/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp
index 6817be23be5f8..854db0ff6864c 100644
--- a/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp
+++ b/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp
@@ -858,13 +858,14 @@ bool IndirectCallPromoter::isProfitableToCompareVTables(
auto &Candidate = Candidates[I];
auto &VTableGUIDAndCounts = Candidate.VTableGUIDAndCounts;
- LLVM_DEBUG(dbgs() << " Candidate " << I << " FunctionCount: "
- << Candidate.Count << ", VTableCounts:");
- // Add [[maybe_unused]] since <GUID, Count> are only used by LLVM_DEBUG.
- for ([[maybe_unused]] auto &[GUID, Count] : VTableGUIDAndCounts)
- LLVM_DEBUG(dbgs() << " {" << Symtab->getGlobalVariable(GUID)->getName()
- << ", " << Count << "}");
- LLVM_DEBUG(dbgs() << "\n");
+ LLVM_DEBUG({
+ dbgs() << " Candidate " << I << " FunctionCount: " << Candidate.Count
+ << ", VTableCounts:";
+ for (const auto &[GUID, Count] : VTableGUIDAndCounts)
+ dbgs() << " {" << Symtab->getGlobalVariable(GUID)->getName() << ", "
+ << Count << "}";
+ dbgs() << "\n";
+ });
uint64_t CandidateVTableCount = 0;
More information about the llvm-commits
mailing list