[utils] Fix UpdateTestChecks case where 2 runs differ for last label
authorMircea Trofin <mtrofin@google.com>
Fri, 11 Dec 2020 00:15:18 +0000 (16:15 -0800)
committerMircea Trofin <mtrofin@google.com>
Tue, 15 Dec 2020 15:16:54 +0000 (07:16 -0800)
commite2dc306b1ac71258e6ce40a66e778527f282c355
treec8d9f9b3238772b5f081a53f5d397db6945074fa
parent2b09dedac4c824c51bc0a8934b33c0f50ce0e126
[utils] Fix UpdateTestChecks case where 2 runs differ for last label

Two RUN lines produce outputs that, each, have some common parts and
some different parts. The common parts are checked under label A. The
differing parts are associated to a function and checked under labels B
and C, respectivelly.
When build_function_body_dictionary is called for the first RUN line, it
will attribute the function body to labels A and C. When the second RUN
is passed to build_function_body_dictionary, it sees that the function
body under A is different from what it has. If in this second RUN line,
A were at the end of the prefixes list, A's body is still kept
associated with the first run's function.

When we output the function body (i.e. add_checks), we stop after
emitting for the first prefix matching that function. So we end up with
the wrong function body (first RUN's A-association).

There is no reason to special-case the last label in the prefixes list,
and the fix is to always clear a label association if we find a RUN line
where the body is different.

Differential Revision: https://reviews.llvm.org/D93078
12 files changed:
clang/test/utils/update_cc_test_checks/Inputs/prefix-never-matches.cpp [new file with mode: 0644]
clang/test/utils/update_cc_test_checks/prefix-never-matches.test [new file with mode: 0644]
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/common-label-different-bodies-1.ll [new file with mode: 0644]
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/common-label-different-bodies-2.ll [new file with mode: 0644]
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/common-label-different-bodies-3.ll [new file with mode: 0644]
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/prefix-never-matches.ll [new file with mode: 0644]
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/common-label-different-bodies.test [new file with mode: 0644]
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/prefix-never-matches.test [new file with mode: 0644]
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/prefix-never-matches.ll [new file with mode: 0644]
llvm/test/tools/UpdateTestChecks/update_test_checks/prefix-never-matches.test [new file with mode: 0644]
llvm/utils/UpdateTestChecks/common.py
llvm/utils/update_test_prefix.py