diff --git a/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/on_the_fly_arg_change.ll.initially_disabled.expected b/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/on_the_fly_arg_change.ll.initially_disabled.expected new file mode 100644 --- /dev/null +++ b/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/on_the_fly_arg_change.ll.initially_disabled.expected @@ -0,0 +1,42 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --scrub-attributes --disable +; RUN: opt -S < %s | FileCheck %s + +declare void @foo() + +define void @check_lines_1() { + ret void +} + +; UTC_ARGS: --disable + +; A check line that would not be auto generated. +; CHECK: define void @no_check_lines() { +define void @no_check_lines() { + ret void +} + +; UTC_ARGS: --enable + +define void @check_lines_2() { +; CHECK-LABEL: define {{[^@]+}}@check_lines_2() +; CHECK-NEXT: ret void +; + ret void +} + +define void @scrub() { +; CHECK-LABEL: define {{[^@]+}}@scrub() +; CHECK-NEXT: call void @foo() +; CHECK-NEXT: ret void +; + call void @foo() readnone + ret void +} + +define i32 @signature(i32 %arg) { +; CHECK-LABEL: define {{[^@]+}}@signature +; CHECK-SAME: (i32 [[ARG:%.*]]) +; CHECK-NEXT: ret i32 [[ARG]] +; + ret i32 %arg +} diff --git a/llvm/test/tools/UpdateTestChecks/update_test_checks/on_the_fly_arg_change.test b/llvm/test/tools/UpdateTestChecks/update_test_checks/on_the_fly_arg_change.test --- a/llvm/test/tools/UpdateTestChecks/update_test_checks/on_the_fly_arg_change.test +++ b/llvm/test/tools/UpdateTestChecks/update_test_checks/on_the_fly_arg_change.test @@ -4,3 +4,13 @@ ## Check that running the script again does not change the result: # RUN: %update_test_checks %t.ll # RUN: diff -u %t.ll %S/Inputs/on_the_fly_arg_change.ll.expected +## Check that the --disable flag is added to the initial UTC_ARGS: +# RUN: cp -f %S/Inputs/on_the_fly_arg_change.ll %t.ll +# RUN: %update_test_checks --function-signature --scrub-attributes --disable %t.ll +# RUN: diff -u %t.ll %S/Inputs/on_the_fly_arg_change.ll.initially_disabled.expected +## Check that the --disable flag from UTC_ARGS is used: +# RUN: %update_test_checks %t.ll +# RUN: diff -u %t.ll %S/Inputs/on_the_fly_arg_change.ll.initially_disabled.expected +## Check that UTC_ARGS: is parsed after the real command line arguments: +# RUN: %update_test_checks --enable %t.ll +# RUN: diff -u %t.ll %S/Inputs/on_the_fly_arg_change.ll.initially_disabled.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 @@ -396,19 +396,30 @@ if prefixes.count(prefix) > 1: warn("Supplied prefix '%s' is not unique in the prefix list." % (prefix,)) + def get_autogennote_suffix(parser, args): - autogenerated_note_args = '' - for k, v in args._get_kwargs(): - if parser.get_default(k) == v or k == 'tests' or k == 'update_only' or k == 'opt_binary': - continue - k = k.replace('_', '-') - if type(v) is bool: - autogenerated_note_args += '--%s ' % (k) - else: - autogenerated_note_args += '--%s %s ' % (k, v) - if autogenerated_note_args: - autogenerated_note_args = ' %s %s' % (UTC_ARGS_KEY, autogenerated_note_args[:-1]) - return autogenerated_note_args + autogenerated_note_args = '' + for action in parser._actions: + if not hasattr(args, action.dest): + continue # Ignore options such as --help that aren't included in args + # Ignore parameters such as paths to the binary or the list of tests + if action.dest in ('tests', 'update_only', 'opt_binary', 'llc_binary', + 'clang', 'opt', 'llvm_bin', 'verbose'): + continue + value = getattr(args, action.dest) + if action.const is not None: # action stores a constant (usually True/False) + # Skip actions with different constant values (this happens with boolean + # --foo/--no-foo options) + if value != action.const: + continue + if parser.get_default(action.dest) == value: + continue # Don't add default values + autogenerated_note_args += action.option_strings[0] + ' ' + if action.const is None: # action takes a parameter + autogenerated_note_args += '%s ' % value + if autogenerated_note_args: + autogenerated_note_args = ' %s %s' % (UTC_ARGS_KEY, autogenerated_note_args[:-1]) + return autogenerated_note_args def check_for_command(line, parser, args, argv):