[llvm] Fix non-determinism in debuginfo (PR #68332)

Markus Böck via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 5 13:07:23 PDT 2023


================
@@ -314,6 +317,25 @@ class AssignmentTrackingPass : public PassInfoMixin<AssignmentTrackingPass> {
 
 /// Return true if assignment tracking is enabled for module \p M.
 bool isAssignmentTrackingEnabled(const Module &M);
+
+template <> struct DenseMapInfo<at::VarRecord> {
+  static inline at::VarRecord getEmptyKey() {
+    return at::VarRecord{nullptr, nullptr};
+  }
+
+  static inline at::VarRecord getTombstoneKey() {
+    return at::VarRecord{nullptr, nullptr};
+  }
----------------
zero9178 wrote:

The tombstone key and empty key mustn't be equal as this breaks the implementation of `DenseMap`. It can lead to accidently finding a member on lookup when it shouldn't or not finding a member when it should.

What you can do is use e.g. `DenseMapInfo<DILocalVariable*>::getTombstoneKey()` as a value here and the corresponding empty key in the other.

https://github.com/llvm/llvm-project/pull/68332


More information about the llvm-commits mailing list