diff --git a/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/named_function_arguments_split.ll.expected b/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/named_function_arguments_split.ll.expected --- a/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/named_function_arguments_split.ll.expected +++ b/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/named_function_arguments_split.ll.expected @@ -1,14 +1,13 @@ -; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2 +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 3 ; Check that we split named function arguments correctly into a separate CHECK line, ; ensuring the opening parenthesis is on the label name, avoiding incorrect label ; matches if function names are not prefix free. -; Note: This is a precommitted test, the current result is incorrect. ; ; RUN: opt < %s -passes=instsimplify -S | FileCheck %s ; define i32 @"foo"(i32 %named) { -; CHECK-LABEL: define i32 @foo -; CHECK-SAME: (i32 [[NAMED:%.*]]) { +; CHECK-LABEL: define i32 @foo( +; CHECK-SAME: i32 [[NAMED:%.*]]) { ; CHECK-NEXT: entry: ; CHECK-NEXT: ret i32 [[NAMED]] ; diff --git a/llvm/test/tools/UpdateTestChecks/update_test_checks/named_function_arguments_split.test b/llvm/test/tools/UpdateTestChecks/update_test_checks/named_function_arguments_split.test --- a/llvm/test/tools/UpdateTestChecks/update_test_checks/named_function_arguments_split.test +++ b/llvm/test/tools/UpdateTestChecks/update_test_checks/named_function_arguments_split.test @@ -1,7 +1,7 @@ # REQUIRES: x86-registered-target ## Basic test checking that update_test_checks.py works correctly -# RUN: cp -f %S/Inputs/named_function_arguments_split.ll %t.ll && %update_test_checks %t.ll --version=2 +# RUN: cp -f %S/Inputs/named_function_arguments_split.ll %t.ll && %update_test_checks %t.ll --version=3 # RUN: diff -u %t.ll %S/Inputs/named_function_arguments_split.ll.expected ## Check that running the script again does not change the result: -# RUN: %update_test_checks %t.ll --version=2 +# RUN: %update_test_checks %t.ll --version=3 # RUN: diff -u %t.ll %S/Inputs/named_function_arguments_split.ll.expected diff --git a/llvm/utils/UpdateTestChecks/common.py b/llvm/utils/UpdateTestChecks/common.py --- a/llvm/utils/UpdateTestChecks/common.py +++ b/llvm/utils/UpdateTestChecks/common.py @@ -24,8 +24,10 @@ 1: Initial version, used by tests that don't specify --version explicitly. 2: --function-signature is now enabled by default and also checks return type/attributes. +3: Opening parenthesis of function args is kept on the first LABEL line + in case arguments are split to a separate SAME line. """ -DEFAULT_VERSION = 2 +DEFAULT_VERSION = 3 class Regex(object): @@ -1277,13 +1279,27 @@ )[0] func_name_separator = func_dict[checkprefix][func_name].func_name_separator if "[[" in args_and_sig: + # Captures in label lines are not supported, thus split into a -LABEL + # and a separate -SAME line that contains the arguments with captures. + args_and_sig_prefix = "" + if version >= 3 and args_and_sig.startswith("("): + # Ensure the "(" separating function name and arguments is in the + # label line. This is required in case of function names that are + # prefixes of each other. Otherwise, the label line for "foo" might + # incorrectly match on "foo.specialized". + args_and_sig_prefix = args_and_sig[0] + args_and_sig = args_and_sig[1:] + + # Removing args_and_sig from the label match line requires + # func_name_separator to be empty. Otherwise, the match will not work. + assert func_name_separator == "" output_lines.append( check_label_format % ( checkprefix, funcdef_attrs_and_ret, func_name, - "", + args_and_sig_prefix, func_name_separator, ) )