[llvm] cbaae61 - [DebugInstrRef] Use DenseMap for ValueToLoc (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 18 08:02:21 PST 2022
Author: Nikita Popov
Date: 2022-01-18T17:02:14+01:00
New Revision: cbaae614224211d01b385227e7efb447c87fc3ce
URL: https://github.com/llvm/llvm-project/commit/cbaae614224211d01b385227e7efb447c87fc3ce
DIFF: https://github.com/llvm/llvm-project/commit/cbaae614224211d01b385227e7efb447c87fc3ce.diff
LOG: [DebugInstrRef] Use DenseMap for ValueToLoc (NFC)
Just replacing std::map with DenseMap here is a major regression
-- because this code used an identity hash for ValueIDNum.
Because ValueIDNum is composed of multiple components, it is
important that we use a reasonably good hash function here, so
switch it to hash_value. DenseMapInfo::getHashValue<uint64_t>
would not be sufficient.
This gives a -0.8% geomean improvement on CTMark ReleaseLTO-g.
Added:
Modified:
llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
index ad8472c436ab0..5d72428f1aecf 100644
--- a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
+++ b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
@@ -272,7 +272,7 @@ class TransferTracker {
};
// Map of the preferred location for each value.
- std::map<ValueIDNum, LocIdx> ValueToLoc;
+ DenseMap<ValueIDNum, LocIdx> ValueToLoc;
ActiveMLocs.reserve(VLocs.size());
ActiveVLocs.reserve(VLocs.size());
diff --git a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h
index 6423ff74b563a..9e9c0ce394fd5 100644
--- a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h
+++ b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h
@@ -1082,7 +1082,9 @@ template <> struct DenseMapInfo<ValueIDNum> {
return ValueIDNum::TombstoneValue;
}
- static unsigned getHashValue(const ValueIDNum &Val) { return Val.asU64(); }
+ static unsigned getHashValue(const ValueIDNum &Val) {
+ return hash_value(Val.asU64());
+ }
static bool isEqual(const ValueIDNum &A, const ValueIDNum &B) {
return A == B;
More information about the llvm-commits
mailing list