Skip to content

Commit fb19bdd

Browse files
[SPIRV] Avoid repeated hash lookups (NFC) (llvm#128398)
1 parent 9dd8c14 commit fb19bdd

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,10 @@ struct ModuleAnalysisInfo {
197197
// Convert MBB's number to corresponding ID register.
198198
Register getOrCreateMBBRegister(const MachineBasicBlock &MBB) {
199199
auto Key = std::make_pair(MBB.getParent(), MBB.getNumber());
200-
auto It = BBNumToRegMap.find(Key);
201-
if (It != BBNumToRegMap.end())
202-
return It->second;
203-
Register NewReg = Register::index2VirtReg(getNextID());
204-
BBNumToRegMap[Key] = NewReg;
205-
return NewReg;
200+
auto [It, Inserted] = BBNumToRegMap.try_emplace(Key);
201+
if (Inserted)
202+
It->second = Register::index2VirtReg(getNextID());
203+
return It->second;
206204
}
207205
};
208206
} // namespace SPIRV

0 commit comments

Comments
 (0)