[all-commits] [llvm/llvm-project] 02debc: update_test_checks: improve IR value name stabilit...

Nicolai Hähnle via All-commits all-commits at lists.llvm.org
Fri Oct 4 05:51:34 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 02debcef12793b5bf926a41a24ede18dc50eb18b
      https://github.com/llvm/llvm-project/commit/02debcef12793b5bf926a41a24ede18dc50eb18b
  Author: Nicolai Hähnle <nicolai.haehnle at amd.com>
  Date:   2024-10-04 (Fri, 04 Oct 2024)

  Changed paths:
    A llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/stable_ir_values5.ll
    A llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/stable_ir_values5.ll.expected
    A llvm/test/tools/UpdateTestChecks/update_test_checks/stable_ir_values5.test
    M llvm/utils/UpdateTestChecks/common.py

  Log Message:
  -----------
  update_test_checks: improve IR value name stability (#110940)

By default, UTC attempts to keep the produced diff small by keeping IR
value name variables stable. The old algorithm was roughly:

1. Compute a diff between the old and new check lines, where
   "uncommitted" variable names are replaced by a wildcard.
   This leads to a set of non-crossing "candidate" pairs of
   (old line, new line) that we can try to make equal.

2. Greedily walk this list of candidates, committing to variable names
   that make candidate lines equal if possible.

The greedy approach in the second step has the downside that committing
to a variable name greedily can sometimes prevent many subsequent
candidates from getting the variable name assignment that would make
them equal.

We keep the first step as-is, but replace the second one by an algorithm
that finds a large independent set of candidates, i.e. candidate pairs
of (old line, new line) which are non-conflicting in the sense that
their desired variable name mappings are not in conflict.

We find the large independent set by greedily assigning a coloring to
the conflict graph and taking the largest color class. We then commit to
all the variable name mappings which are desired by candidates in this
largest color class.

As before, we then recurse into regions between matching lines. This is
required in large cases. For example, running this algorithm at the
top-level of the new test case (stable_ir_values5.ll) matches up most of
the instructions, but not the names of the result values of all the
`load`s. This is because (unlike e.g. the getelementptrs) the load
instructions are all equal except for variable names, and so step 1 (the
diff algorithm) doesn't consider them as candidates. However, they are
trivially matched by recursion.

This also happens to fix a bug in tracking line indices that went
unnoticed previously...

As is usually the case with these changes, the quality improvement is
hard to see from the diff of this patch. However, it becomes obvious
when
comparing the diff of stable_ir_values5.ll against
stable_ir_value5.ll.expected
before and after this change.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list