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

Paul Kirth via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 6 12:44:23 PDT 2023


================
@@ -314,6 +317,27 @@ 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{DenseMapInfo<DILocalVariable *>::getEmptyKey(),
+                         DenseMapInfo<DILocation *>::getEmptyKey()};
+  }
+
+  static inline at::VarRecord getTombstoneKey() {
+    return at::VarRecord{DenseMapInfo<DILocalVariable *>::getTombstoneKey(),
+                         DenseMapInfo<DILocation *>::getTombstoneKey()};
+  }
+
+  static unsigned getHashValue(const at::VarRecord &Var) {
+    return hash_combine(Var.Var, Var.DL);
+  }
+
+  static bool isEqual(const at::VarRecord &A, const at::VarRecord &B) {
+    return A == B;
+  }
+};
+
----------------
ilovepi wrote:

So I ended up going back to the `Varrecord` w/ the `DenseMapInfo` specialization, and placed it as close as possible to the class def. On the downside, it splits the `at` namespace. 

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


More information about the llvm-commits mailing list