diff options
Diffstat (limited to 'llvm')
4 files changed, 55 insertions, 0 deletions
diff --git a/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/global_regex.ll b/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/global_regex.ll new file mode 100644 index 0000000..ccecb0d --- /dev/null +++ b/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/global_regex.ll @@ -0,0 +1,15 @@ +; RUN: opt < %s -S | FileCheck %s + +@Bar = global i32 0 +@OnlyFoo = global i32 1 +@Baz = global i32 2 + +define i32 @t() { + %v1 = load i32, ptr @Bar + %v2 = load i32, ptr @OnlyFoo + %v3 = load i32, ptr @Baz + %a1 = add i32 %v1, %v2 + %a2 = add i32 %a1, %v3 + ret i32 %a2 +} + diff --git a/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/global_regex.ll.expected b/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/global_regex.ll.expected new file mode 100644 index 0000000..089b62f --- /dev/null +++ b/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/global_regex.ll.expected @@ -0,0 +1,27 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals --global-value-regex "OnlyFoo" +; RUN: opt < %s -S | FileCheck %s + +@Bar = global i32 0 +@OnlyFoo = global i32 1 +@Baz = global i32 2 + +;. +; CHECK: @[[ONLYFOO:[a-zA-Z0-9_$"\\.-]+]] = global i32 1 +;. +define i32 @t() { +; CHECK-LABEL: @t( +; CHECK-NEXT: [[V1:%.*]] = load i32, ptr @Bar, align 4 +; CHECK-NEXT: [[V2:%.*]] = load i32, ptr @OnlyFoo, align 4 +; CHECK-NEXT: [[V3:%.*]] = load i32, ptr @Baz, align 4 +; CHECK-NEXT: [[A1:%.*]] = add i32 [[V1]], [[V2]] +; CHECK-NEXT: [[A2:%.*]] = add i32 [[A1]], [[V3]] +; CHECK-NEXT: ret i32 [[A2]] +; + %v1 = load i32, ptr @Bar + %v2 = load i32, ptr @OnlyFoo + %v3 = load i32, ptr @Baz + %a1 = add i32 %v1, %v2 + %a2 = add i32 %a1, %v3 + ret i32 %a2 +} + diff --git a/llvm/test/tools/UpdateTestChecks/update_test_checks/global_regex.test b/llvm/test/tools/UpdateTestChecks/update_test_checks/global_regex.test new file mode 100644 index 0000000..debdde9 --- /dev/null +++ b/llvm/test/tools/UpdateTestChecks/update_test_checks/global_regex.test @@ -0,0 +1,7 @@ +# REQUIRES: x86-registered-target +## Basic test checking that update_test_checks.py works correctly +# RUN: cp -f %S/Inputs/global_regex.ll %t.ll && %update_test_checks %t.ll --check-globals --global-value-regex "OnlyFoo" +# RUN: diff -u %t.ll %S/Inputs/global_regex.ll.expected +## Verify that running without the --global-value-regex flag respects UTC_ARGS +# RUN: %update_test_checks %t.ll +# RUN: diff -u %t.ll %S/Inputs/global_regex.ll.expected diff --git a/llvm/utils/UpdateTestChecks/common.py b/llvm/utils/UpdateTestChecks/common.py index f9c923f..fe333d4 100644 --- a/llvm/utils/UpdateTestChecks/common.py +++ b/llvm/utils/UpdateTestChecks/common.py @@ -209,6 +209,7 @@ def parse_commandline_args(parser): "--version", type=int, default=1, help="The version of output format" ) args = parser.parse_args() + # TODO: This should not be handled differently from the other options global _verbose, _global_value_regex, _global_hex_value_regex _verbose = args.verbose _global_value_regex = args.global_value_regex @@ -220,6 +221,11 @@ def parse_args(parser, argv): args = parser.parse_args(argv) if args.version >= 2: args.function_signature = True + # TODO: This should not be handled differently from the other options + global _verbose, _global_value_regex, _global_hex_value_regex + _verbose = args.verbose + _global_value_regex = args.global_value_regex + _global_hex_value_regex = args.global_hex_value_regex return args |