[llvm] dcd4d0a - [UTC] Honor global-value-regex in UTC_ARGS

Johannes Doerfert via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 23 10:40:49 PDT 2023


Author: Johannes Doerfert
Date: 2023-08-23T10:40:30-07:00
New Revision: dcd4d0a7904190350ec5b06f94e2edee13bd6434

URL: https://github.com/llvm/llvm-project/commit/dcd4d0a7904190350ec5b06f94e2edee13bd6434
DIFF: https://github.com/llvm/llvm-project/commit/dcd4d0a7904190350ec5b06f94e2edee13bd6434.diff

LOG: [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.

Added: 
    llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/global_regex.ll
    llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/global_regex.ll.expected
    llvm/test/tools/UpdateTestChecks/update_test_checks/global_regex.test

Modified: 
    llvm/utils/UpdateTestChecks/common.py

Removed: 
    


################################################################################
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 00000000000000..ccecb0d86df802
--- /dev/null
+++ b/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/global_regex.ll
@@ -0,0 +1,15 @@
+; RUN: opt < %s -S | FileCheck %s
+
+ at Bar = global i32 0
+ at OnlyFoo = global i32 1
+ at 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 00000000000000..089b62f9ceccff
--- /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
+
+ at Bar = global i32 0
+ at OnlyFoo = global i32 1
+ at 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 00000000000000..debdde95d185d0
--- /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 f9c923fa91ac4b..fe333d4973035a 100644
--- a/llvm/utils/UpdateTestChecks/common.py
+++ b/llvm/utils/UpdateTestChecks/common.py
@@ -209,6 +209,7 @@ def __call__(self, parser, namespace, values, option_string=None):
         "--version", type=int, default=1, help="The version of output format"
     )
     args = parser.parse_args()
+    # TODO: This should not be handled 
diff erently 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 
diff erently 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
 
 


        


More information about the llvm-commits mailing list