[Mlir-commits] [mlir] [LLVMIR] Avoid repeated hash lookups (NFC) (PR #107428)

Kazu Hirata llvmlistbot at llvm.org
Thu Sep 5 09:57:33 PDT 2024


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

None

>From 26cdbcdbba14afd03012fb279e5b63f3c54a8ab6 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Thu, 5 Sep 2024 08:43:51 -0700
Subject: [PATCH] [LLVMIR] Avoid repeated hash lookups (NFC)

---
 mlir/lib/Target/LLVMIR/ModuleImport.cpp | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/mlir/lib/Target/LLVMIR/ModuleImport.cpp b/mlir/lib/Target/LLVMIR/ModuleImport.cpp
index bd761650534880..d1732cb808928a 100644
--- a/mlir/lib/Target/LLVMIR/ModuleImport.cpp
+++ b/mlir/lib/Target/LLVMIR/ModuleImport.cpp
@@ -1021,9 +1021,8 @@ ModuleImport::getConstantsToConvert(llvm::Constant *constant) {
     llvm::Constant *current = workList.back();
     // Collect all dependencies of the current constant and add them to the
     // adjacency list if none has been computed before.
-    auto adjacencyIt = adjacencyLists.find(current);
-    if (adjacencyIt == adjacencyLists.end()) {
-      adjacencyIt = adjacencyLists.try_emplace(current).first;
+    auto [adjacencyIt, inserted] = adjacencyLists.try_emplace(current);
+    if (inserted) {
       // Add all constant operands to the adjacency list and skip any other
       // values such as basic block addresses.
       for (llvm::Value *operand : current->operands())



More information about the Mlir-commits mailing list