[llvm] [ICP] Use a block with LLVM_DEBUG (NFC) (PR #140387)
    via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Sat May 17 10:48:26 PDT 2025
    
    
  
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
Using a block inside LLVM_DEBUG allows us to simplify the code with a
single LLVM_DEBUG and remove maybe_unused.
---
Full diff: https://github.com/llvm/llvm-project/pull/140387.diff
1 Files Affected:
- (modified) llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp (+8-7) 
``````````diff
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;
 
``````````
</details>
https://github.com/llvm/llvm-project/pull/140387
    
    
More information about the llvm-commits
mailing list