diff --git a/llvm/lib/Target/WebAssembly/WebAssemblySortRegion.cpp b/llvm/lib/Target/WebAssembly/WebAssemblySortRegion.cpp index cd84e68aed140..0469fbf15b251 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblySortRegion.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblySortRegion.cpp @@ -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>(ML); - return LoopMap[ML].get(); + auto [It, Inserted] = LoopMap.try_emplace(ML); + if (Inserted) + It->second = std::make_unique>(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>(WE); - return ExceptionMap[WE].get(); + auto [It, Inserted] = ExceptionMap.try_emplace(WE); + if (Inserted) + It->second = + std::make_unique>(WE); + return It->second.get(); } }