Skip to content

Commit 34cebaf

Browse files
[Instrumentation] Avoid repeated hash lookups (NFC) (#128128)
1 parent f964377 commit 34cebaf

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1362,10 +1362,10 @@ void AddressSanitizer::instrumentMemIntrinsic(MemIntrinsic *MI,
13621362

13631363
/// Check if we want (and can) handle this alloca.
13641364
bool AddressSanitizer::isInterestingAlloca(const AllocaInst &AI) {
1365-
auto PreviouslySeenAllocaInfo = ProcessedAllocas.find(&AI);
1365+
auto [It, Inserted] = ProcessedAllocas.try_emplace(&AI);
13661366

1367-
if (PreviouslySeenAllocaInfo != ProcessedAllocas.end())
1368-
return PreviouslySeenAllocaInfo->getSecond();
1367+
if (!Inserted)
1368+
return It->getSecond();
13691369

13701370
bool IsInteresting =
13711371
(AI.getAllocatedType()->isSized() &&
@@ -1382,7 +1382,7 @@ bool AddressSanitizer::isInterestingAlloca(const AllocaInst &AI) {
13821382
// safe allocas are not interesting
13831383
!(SSGI && SSGI->isSafe(AI)));
13841384

1385-
ProcessedAllocas[&AI] = IsInteresting;
1385+
It->second = IsInteresting;
13861386
return IsInteresting;
13871387
}
13881388

0 commit comments

Comments
 (0)