[llvm] 2d7d74d - [LiveDebugValues] Avoid repeated hash lookups (NFC) (#109242)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 19 09:15:10 PDT 2024
Author: Kazu Hirata
Date: 2024-09-19T09:15:06-07:00
New Revision: 2d7d74d990bf7a7211910e05a15d506c63295c53
URL: https://github.com/llvm/llvm-project/commit/2d7d74d990bf7a7211910e05a15d506c63295c53
DIFF: https://github.com/llvm/llvm-project/commit/2d7d74d990bf7a7211910e05a15d506c63295c53.diff
LOG: [LiveDebugValues] Avoid repeated hash lookups (NFC) (#109242)
Added:
Modified:
llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h
index d9851ad13eab24..5c095e79599f6a 100644
--- a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h
+++ b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h
@@ -484,22 +484,16 @@ class DbgOpIDMap {
private:
DbgOpID insertConstOp(MachineOperand &MO) {
- auto ExistingIt = ConstOpToID.find(MO);
- if (ExistingIt != ConstOpToID.end())
- return ExistingIt->second;
- DbgOpID ID(true, ConstOps.size());
- ConstOpToID.insert(std::make_pair(MO, ID));
- ConstOps.push_back(MO);
- return ID;
+ auto [It, Inserted] = ConstOpToID.try_emplace(MO, true, ConstOps.size());
+ if (Inserted)
+ ConstOps.push_back(MO);
+ return It->second;
}
DbgOpID insertValueOp(ValueIDNum VID) {
- auto ExistingIt = ValueOpToID.find(VID);
- if (ExistingIt != ValueOpToID.end())
- return ExistingIt->second;
- DbgOpID ID(false, ValueOps.size());
- ValueOpToID.insert(std::make_pair(VID, ID));
- ValueOps.push_back(VID);
- return ID;
+ auto [It, Inserted] = ValueOpToID.try_emplace(VID, false, ValueOps.size());
+ if (Inserted)
+ ValueOps.push_back(VID);
+ return It->second;
}
};
More information about the llvm-commits
mailing list