Do not walk one map while inserting into it Joining a lattice with itself says nothing new, and the loop below now walks the other side's map while inserting into this one, which the rehash would not survive. Say the first, which settles the second. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016zErYp7upmqr4NHfhod9UD
diff --git a/enzyme/Enzyme/MLIR/Analysis/DataFlowLattice.h b/enzyme/Enzyme/MLIR/Analysis/DataFlowLattice.h index 17ae17c..40048ee 100644 --- a/enzyme/Enzyme/MLIR/Analysis/DataFlowLattice.h +++ b/enzyme/Enzyme/MLIR/Analysis/DataFlowLattice.h
@@ -254,6 +254,11 @@ const auto &rhs = static_cast<const MapOfSetsLattice<KeyT, ElementT> &>(other); + // Joining with itself says nothing new, and walking one map while inserting + // into it would not survive the rehash. + if (this == &rhs) + return ChangeResult::NoChange; + // A key only this side has is left as it is, so only the other side's keys // are worth walking. Taking the union of both first meant every join cost // the size of what had been accumulated, which in a fixpoint is joined into