[llvm] [FuzzMutate] Avoid repeated hash lookups (NFC) (PR #109903)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 24 21:24:58 PDT 2024


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

None

>From 7e64f6e82cb3df9ea8047a7c15b996aa2e5da480 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Tue, 24 Sep 2024 17:38:31 -0700
Subject: [PATCH] [FuzzMutate] Avoid repeated hash lookups (NFC)

---
 llvm/lib/FuzzMutate/IRMutator.cpp | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/llvm/lib/FuzzMutate/IRMutator.cpp b/llvm/lib/FuzzMutate/IRMutator.cpp
index 72e0de59376076..e1fe6c8d89ab05 100644
--- a/llvm/lib/FuzzMutate/IRMutator.cpp
+++ b/llvm/lib/FuzzMutate/IRMutator.cpp
@@ -623,9 +623,11 @@ void ShuffleBlockStrategy::mutate(BasicBlock &BB, RandomIRBuilder &IB) {
   auto getAliveChildren = [&AliveInstsLookup](Instruction *I) {
     SmallSetVector<size_t, 8> Children;
     for (Value *U : I->users()) {
-      Instruction *P = dyn_cast<Instruction>(U);
-      if (P && AliveInstsLookup.count(P))
-        Children.insert(AliveInstsLookup[P]);
+      if (Instruction *P = dyn_cast<Instruction>(U)) {
+        auto It = AliveInstsLookup.find(P);
+        if (It != AliveInstsLookup.end())
+          Children.insert(It->second);
+      }
     }
     return Children;
   };



More information about the llvm-commits mailing list