[llvm] [LiveDebugValues] Avoid repeated hash lookups (NFC) (PR #109242)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 18 23:20:23 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-debuginfo
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/109242.diff
1 Files Affected:
- (modified) llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h (+8-14)
``````````diff
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;
}
};
``````````
</details>
https://github.com/llvm/llvm-project/pull/109242
More information about the llvm-commits
mailing list