[llvm] [IR] Use llvm::for_each (NFC) (PR #146989)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 3 19:31:31 PDT 2025


https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/146989

We can pass a range to llvm::for_each.


>From cef1207941f679f3d701a09df1cafd5e1d98d18e Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Thu, 3 Jul 2025 17:56:24 -0700
Subject: [PATCH] [IR] Use llvm::for_each (NFC)

We can pass a range to llvm::for_each.
---
 llvm/lib/IR/LegacyPassManager.cpp | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/llvm/lib/IR/LegacyPassManager.cpp b/llvm/lib/IR/LegacyPassManager.cpp
index c8f1606ea06cb..1d9a61ce4a10b 100644
--- a/llvm/lib/IR/LegacyPassManager.cpp
+++ b/llvm/lib/IR/LegacyPassManager.cpp
@@ -120,7 +120,7 @@ void PMDataManager::emitInstrCountChangedRemark(
   // If no function was passed in, then we're either a module pass or an
   // CGSCC pass.
   if (!CouldOnlyImpactOneFunction)
-    std::for_each(M.begin(), M.end(), UpdateFunctionChanges);
+    llvm::for_each(M, UpdateFunctionChanges);
   else
     UpdateFunctionChanges(*F);
 
@@ -197,9 +197,7 @@ void PMDataManager::emitInstrCountChangedRemark(
   // Are we looking at more than one function? If so, emit remarks for all of
   // the functions in the module. Otherwise, only emit one remark.
   if (!CouldOnlyImpactOneFunction)
-    std::for_each(FunctionToInstrCount.keys().begin(),
-                  FunctionToInstrCount.keys().end(),
-                  EmitFunctionSizeChangedRemark);
+    llvm::for_each(FunctionToInstrCount.keys(), EmitFunctionSizeChangedRemark);
   else
     EmitFunctionSizeChangedRemark(F->getName().str());
 }



More information about the llvm-commits mailing list