diff --git a/clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.funcsig.v2.expected b/clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.funcsig.v2.expected --- a/clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.funcsig.v2.expected +++ b/clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.funcsig.v2.expected @@ -1,4 +1,4 @@ -// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature --version 2 +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2 // Example input for update_cc_test_checks // RUN: %clang_cc1 -triple=x86_64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s diff --git a/clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.funcsig.v2.expected b/clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.v2.expected copy from clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.funcsig.v2.expected copy to clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.v2.expected --- a/clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.funcsig.v2.expected +++ b/clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.v2.expected @@ -1,4 +1,4 @@ -// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature --version 2 +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2 // Example input for update_cc_test_checks // RUN: %clang_cc1 -triple=x86_64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s diff --git a/clang/test/utils/update_cc_test_checks/mangled_names.test b/clang/test/utils/update_cc_test_checks/mangled_names.test --- a/clang/test/utils/update_cc_test_checks/mangled_names.test +++ b/clang/test/utils/update_cc_test_checks/mangled_names.test @@ -19,3 +19,8 @@ ## Also try --version 2 # RUN: %update_cc_test_checks %t.c --function-signature --version 2 # RUN: diff -u %t.c %S/Inputs/mangled_names.c.funcsig.v2.expected +## Restore the original file without --function-signature and check that +## --version 2 will implicitly enable it. +# RUN: cp -f %S/Inputs/mangled_names.c %t.c +# RUN: %update_cc_test_checks %t.c --version 2 +# RUN: diff -u %t.c %S/Inputs/mangled_names.c.v2.expected diff --git a/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/basic.ll.v2.expected b/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/basic.ll.v2.expected new file mode 100644 --- /dev/null +++ b/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/basic.ll.v2.expected @@ -0,0 +1,65 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2 +; Example input for update_test_checks (taken from test/Transforms/InstSimplify/add.ll) +; RUN: opt < %s -passes=instsimplify -S | FileCheck %s + +define i32 @common_sub_operand(i32 %X, i32 %Y) { +; CHECK-LABEL: define i32 @common_sub_operand +; CHECK-SAME: (i32 [[X:%.*]], i32 [[Y:%.*]]) { +; CHECK-NEXT: ret i32 [[X]] +; + %Z = sub i32 %X, %Y + %Q = add i32 %Z, %Y + ret i32 %Q +} + +define i32 @negated_operand(i32 %x) { +; CHECK-LABEL: define i32 @negated_operand +; CHECK-SAME: (i32 [[X:%.*]]) { +; CHECK-NEXT: ret i32 0 +; + %negx = sub i32 0, %x + %r = add i32 %negx, %x + ret i32 %r +} + +define <2 x i32> @negated_operand_commute_vec(<2 x i32> %x) { +; CHECK-LABEL: define <2 x i32> @negated_operand_commute_vec +; CHECK-SAME: (<2 x i32> [[X:%.*]]) { +; CHECK-NEXT: ret <2 x i32> zeroinitializer +; + %negx = sub <2 x i32> zeroinitializer, %x + %r = add <2 x i32> %x, %negx + ret <2 x i32> %r +} + +define i8 @knownnegation(i8 %x, i8 %y) { +; CHECK-LABEL: define i8 @knownnegation +; CHECK-SAME: (i8 [[X:%.*]], i8 [[Y:%.*]]) { +; CHECK-NEXT: ret i8 0 +; + %xy = sub i8 %x, %y + %yx = sub i8 %y, %x + %r = add i8 %xy, %yx + ret i8 %r +} + +define <2 x i8> @knownnegation_commute_vec(<2 x i8> %x, <2 x i8> %y) { +; CHECK-LABEL: define <2 x i8> @knownnegation_commute_vec +; CHECK-SAME: (<2 x i8> [[X:%.*]], <2 x i8> [[Y:%.*]]) { +; CHECK-NEXT: ret <2 x i8> zeroinitializer +; + %xy = sub <2 x i8> %x, %y + %yx = sub <2 x i8> %y, %x + %r = add <2 x i8> %yx, %xy + ret <2 x i8> %r +} + +define i32 @nameless_value(i32 %X) { +; CHECK-LABEL: define i32 @nameless_value +; CHECK-SAME: (i32 [[X:%.*]]) { +; CHECK-NEXT: [[TMP1:%.*]] = sub i32 42, [[X]] +; CHECK-NEXT: ret i32 [[TMP1]] +; + %1 = sub i32 42, %X + ret i32 %1 +} diff --git a/llvm/test/tools/UpdateTestChecks/update_test_checks/basic.test b/llvm/test/tools/UpdateTestChecks/update_test_checks/basic.test --- a/llvm/test/tools/UpdateTestChecks/update_test_checks/basic.test +++ b/llvm/test/tools/UpdateTestChecks/update_test_checks/basic.test @@ -14,3 +14,8 @@ ## added to the update invocation below. # RUN: %update_test_checks %t.ll # RUN: diff -u %t.ll %S/Inputs/basic.ll.funcsig.expected +## Restore the original file without --function-signature and check that +## --version 2 will implicitly enable it and also check the return type. +# RUN: cp -f %S/Inputs/basic.ll %t.ll +# RUN: %update_test_checks %t.ll --version 2 +# RUN: diff -u %t.ll %S/Inputs/basic.ll.v2.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 @@ -22,9 +22,10 @@ Version changelog: 1: Initial version, used by tests that don't specify --version explicitly. -2: --function-signature now also checks return type/attributes. +2: --function-signature is now enabled by default and also checks return + type/attributes. """ -DEFAULT_VERSION = 1 +DEFAULT_VERSION = 2 class Regex(object): """Wrap a compiled regular expression object to allow deep copy of a regexp. @@ -157,6 +158,11 @@ _global_hex_value_regex = args.global_hex_value_regex return args +def parse_args(parser, argv): + args = parser.parse_args(argv) + if args.version >= 2: + args.function_signature = True + return args class InputLineInfo(object): def __init__(self, line, line_number, args, argv): @@ -246,7 +252,7 @@ if not is_regenerate: argv.insert(1, '--version=' + str(DEFAULT_VERSION)) - args = parser.parse_args(argv[1:]) + args = parse_args(parser, argv[1:]) if argparse_callback is not None: argparse_callback(args) if is_regenerate: @@ -1199,6 +1205,8 @@ continue if parser.get_default(action.dest) == value: continue # Don't add default values + if action.dest == 'function_signature' and args.version >= 2: + continue # Enabled by default in version 2 if action.dest == 'filters': # Create a separate option for each filter element. The value is a list # of Filter objects. @@ -1225,7 +1233,7 @@ for option in shlex.split(cmd_m.group('cmd').strip()): if option: argv.append(option) - args = parser.parse_args(filter(lambda arg: arg not in args.tests, argv)) + args = parse_args(parser, filter(lambda arg: arg not in args.tests, argv)) if argparse_callback is not None: argparse_callback(args) return args, argv