From 63217bad0cf0ac0d520f1d140b684a2efad13f19 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Thu, 20 Feb 2025 09:34:06 -0800 Subject: [PATCH] [Instrumentation] Avoid repeated hash lookups (NFC) --- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp index bbe7040121649..8d8d56035a48f 100644 --- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -1362,10 +1362,10 @@ void AddressSanitizer::instrumentMemIntrinsic(MemIntrinsic *MI, /// Check if we want (and can) handle this alloca. bool AddressSanitizer::isInterestingAlloca(const AllocaInst &AI) { - auto PreviouslySeenAllocaInfo = ProcessedAllocas.find(&AI); + auto [It, Inserted] = ProcessedAllocas.try_emplace(&AI); - if (PreviouslySeenAllocaInfo != ProcessedAllocas.end()) - return PreviouslySeenAllocaInfo->getSecond(); + if (!Inserted) + return It->getSecond(); bool IsInteresting = (AI.getAllocatedType()->isSized() && @@ -1382,7 +1382,7 @@ bool AddressSanitizer::isInterestingAlloca(const AllocaInst &AI) { // safe allocas are not interesting !(SSGI && SSGI->isSafe(AI))); - ProcessedAllocas[&AI] = IsInteresting; + It->second = IsInteresting; return IsInteresting; }