[llvm] update_test_checks: improve IR value name stability (PR #110940)
Nicolai Hähnle via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 4 03:16:43 PDT 2024
================
@@ -1534,14 +1534,35 @@ def diffify_line(line, mapper):
candidate_matches = find_diff_matching(lhs_lines, rhs_lines)
- # Apply commits greedily on a match-by-match basis
- matches = [(-1, -1)]
- committed_anything = False
- for lhs_idx, rhs_idx in candidate_matches:
+ candidate_matches = [
+ (old_begin + lhs_idx, new_begin + rhs_idx)
+ for lhs_idx, rhs_idx in candidate_matches
+ ]
+
+ # Candidate matches may conflict if they require conflicting mappings of
+ # names.
+ #
+ # Treat the candidate matches as vertices in a conflict graph. Greedily
+ # color the vertices.
+ class Color:
+ def __init__(self):
+ # (lhs_idx, rhs_idx) of matches in this color
+ self.matches = []
+
+ # rhs_name -> lhs_name mappings required by this color
+ self.mapping = {}
+
+ # lhs_names committed for this color
+ self.committed = set()
+ colors = []
+
+ for match_idx, (lhs_idx, rhs_idx) in enumerate(candidate_matches):
lhs_line = old_line_infos[lhs_idx]
rhs_line = new_line_infos[rhs_idx]
- local_commits = {}
+ compatible_colors = colors[:]
----------------
nhaehnle wrote:
I feel like this is idiomatic Python.
https://github.com/llvm/llvm-project/pull/110940
More information about the llvm-commits
mailing list