Skip to content

[WebAssembly] Avoid repeated hash lookups (NFC) #127960

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions llvm/lib/Target/WebAssembly/WebAssemblySortRegion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ const SortRegion *SortRegionInfo::getRegionFor(const MachineBasicBlock *MBB) {
// WE->contains(ML->getHeader()), but not ML->contains(WE->getHeader()).
if ((ML && !WE) || (ML && WE && WE->contains(ML->getHeader()))) {
// If the smallest region containing MBB is a loop
if (LoopMap.count(ML))
return LoopMap[ML].get();
LoopMap[ML] = std::make_unique<ConcreteSortRegion<MachineLoop>>(ML);
return LoopMap[ML].get();
auto [It, Inserted] = LoopMap.try_emplace(ML);
if (Inserted)
It->second = std::make_unique<ConcreteSortRegion<MachineLoop>>(ML);
return It->second.get();
} else {
// If the smallest region containing MBB is an exception
if (ExceptionMap.count(WE))
return ExceptionMap[WE].get();
ExceptionMap[WE] =
std::make_unique<ConcreteSortRegion<WebAssemblyException>>(WE);
return ExceptionMap[WE].get();
auto [It, Inserted] = ExceptionMap.try_emplace(WE);
if (Inserted)
It->second =
std::make_unique<ConcreteSortRegion<WebAssemblyException>>(WE);
return It->second.get();
}
}

Expand Down