[llvm] update_test_checks: improve IR value name stability (PR #110940)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 4 22:24:58 PDT 2024


Nicolai =?utf-8?q?Hähnle?= <nicolai.haehnle at amd.com>,
Nicolai =?utf-8?q?Hähnle?= <nicolai.haehnle at amd.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/110940 at github.com>


================
@@ -1554,39 +1598,71 @@ def diffify_line(line, mapper):
                     else:
                         break
 
-                if rhs_value.name in local_commits:
+                if rhs_value.name in new_color.mapping:
                     # Same, but for a possible commit happening on the same line
-                    if local_commits[rhs_value.name] == lhs_value.name:
+                    if new_color.color[rhs_value.name] == lhs_value.name:
----------------
dtcxzyw wrote:

I cannot update IR tests after this patch:
```
python3 ../../llvm-project/llvm/utils/update_test_checks.py --opt-binary=bin/opt ../../llvm-project/llvm/test/Transforms/InstCombine/add.ll
```
```
Traceback (most recent call last):
  File "/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/../../llvm-project/llvm/utils/update_test_checks.py", line 370, in <module>
    main()
  File "/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/../../llvm-project/llvm/utils/update_test_checks.py", line 277, in main
    common.add_ir_checks(
  File "/home/dtcxzyw/WorkSpace/Projects/compilers/llvm-project/llvm/utils/UpdateTestChecks/common.py", line 2157, in add_ir_checks
    return add_checks(
  File "/home/dtcxzyw/WorkSpace/Projects/compilers/llvm-project/llvm/utils/UpdateTestChecks/common.py", line 2076, in add_checks
    func_body = generalize_check_lines(
  File "/home/dtcxzyw/WorkSpace/Projects/compilers/llvm-project/llvm/utils/UpdateTestChecks/common.py", line 1844, in generalize_check_lines
    mapping = remap_metavar_names(orig_line_infos, new_line_infos, committed_names)
  File "/home/dtcxzyw/WorkSpace/Projects/compilers/llvm-project/llvm/utils/UpdateTestChecks/common.py", line 1672, in remap_metavar_names
    recurse(0, len(old_line_infos), 0, len(new_line_infos))
  File "/home/dtcxzyw/WorkSpace/Projects/compilers/llvm-project/llvm/utils/UpdateTestChecks/common.py", line 1606, in recurse
    if new_color.color[rhs_value.name] == lhs_value.name:
AttributeError: 'Color' object has no attribute 'color'
```

IIRC it should be `new_color.mapping[rhs_value.name]`.


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


More information about the llvm-commits mailing list