aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Doerfert <johannes@jdoerfert.de>2023-08-20 16:18:12 -0700
committerJohannes Doerfert <johannes@jdoerfert.de>2023-08-23 10:40:30 -0700
commitdcd4d0a7904190350ec5b06f94e2edee13bd6434 (patch)
treecced82b93e711f6ee9b48f69bf9db5a8362d4c22
parent6ff70ec60eae2f973c46c5d1d6a28684f21f1cb4 (diff)
downloadllvm-dcd4d0a7904190350ec5b06f94e2edee13bd6434.zip
llvm-dcd4d0a7904190350ec5b06f94e2edee13bd6434.tar.gz
llvm-dcd4d0a7904190350ec5b06f94e2edee13bd6434.tar.bz2
[UTC] Honor global-value-regex in UTC_ARGS
Without this we cannot update various clang OpenMP tests as the UTC_ARGS version of -global-value-regex is simply ignored. The handling of the flag should be changed to be in line with others, I left TODOs for now.
-rw-r--r--llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/global_regex.ll15
-rw-r--r--llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/global_regex.ll.expected27
-rw-r--r--llvm/test/tools/UpdateTestChecks/update_test_checks/global_regex.test7
-rw-r--r--llvm/utils/UpdateTestChecks/common.py6
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