[llvm] Fix non-determinism in debuginfo (PR #68332)
Orlando Cazalet-Hyams via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 6 05:41:01 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;
+ }
+};
+
----------------
OCHyams wrote:
We could throw away `VarRecord` and use `std::pair` instead to avoid adding this boilerplate (keeping the VarRecord comment next to a `using VarRecord = std::pair<...>` perhaps). I think a case can be made for both approaches, so I'm happy to stick with the path of least resistance.
Please could you move this `struct DenseMapInfo` next to `VarRecord` so that it's easier to notice that it needs updating if a field is added to `VarRecord`.
https://github.com/llvm/llvm-project/pull/68332
More information about the llvm-commits
mailing list