Skip to content

Commit dcd4d0a

Browse files
committed
[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.
1 parent 6ff70ec commit dcd4d0a

File tree

4 files changed

+55
-0
lines changed

4 files changed

+55
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
; RUN: opt < %s -S | FileCheck %s
2+
3+
@Bar = global i32 0
4+
@OnlyFoo = global i32 1
5+
@Baz = global i32 2
6+
7+
define i32 @t() {
8+
%v1 = load i32, ptr @Bar
9+
%v2 = load i32, ptr @OnlyFoo
10+
%v3 = load i32, ptr @Baz
11+
%a1 = add i32 %v1, %v2
12+
%a2 = add i32 %a1, %v3
13+
ret i32 %a2
14+
}
15+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals --global-value-regex "OnlyFoo"
2+
; RUN: opt < %s -S | FileCheck %s
3+
4+
@Bar = global i32 0
5+
@OnlyFoo = global i32 1
6+
@Baz = global i32 2
7+
8+
;.
9+
; CHECK: @[[ONLYFOO:[a-zA-Z0-9_$"\\.-]+]] = global i32 1
10+
;.
11+
define i32 @t() {
12+
; CHECK-LABEL: @t(
13+
; CHECK-NEXT: [[V1:%.*]] = load i32, ptr @Bar, align 4
14+
; CHECK-NEXT: [[V2:%.*]] = load i32, ptr @OnlyFoo, align 4
15+
; CHECK-NEXT: [[V3:%.*]] = load i32, ptr @Baz, align 4
16+
; CHECK-NEXT: [[A1:%.*]] = add i32 [[V1]], [[V2]]
17+
; CHECK-NEXT: [[A2:%.*]] = add i32 [[A1]], [[V3]]
18+
; CHECK-NEXT: ret i32 [[A2]]
19+
;
20+
%v1 = load i32, ptr @Bar
21+
%v2 = load i32, ptr @OnlyFoo
22+
%v3 = load i32, ptr @Baz
23+
%a1 = add i32 %v1, %v2
24+
%a2 = add i32 %a1, %v3
25+
ret i32 %a2
26+
}
27+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# REQUIRES: x86-registered-target
2+
## Basic test checking that update_test_checks.py works correctly
3+
# RUN: cp -f %S/Inputs/global_regex.ll %t.ll && %update_test_checks %t.ll --check-globals --global-value-regex "OnlyFoo"
4+
# RUN: diff -u %t.ll %S/Inputs/global_regex.ll.expected
5+
## Verify that running without the --global-value-regex flag respects UTC_ARGS
6+
# RUN: %update_test_checks %t.ll
7+
# RUN: diff -u %t.ll %S/Inputs/global_regex.ll.expected

llvm/utils/UpdateTestChecks/common.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ def __call__(self, parser, namespace, values, option_string=None):
209209
"--version", type=int, default=1, help="The version of output format"
210210
)
211211
args = parser.parse_args()
212+
# TODO: This should not be handled differently from the other options
212213
global _verbose, _global_value_regex, _global_hex_value_regex
213214
_verbose = args.verbose
214215
_global_value_regex = args.global_value_regex
@@ -220,6 +221,11 @@ def parse_args(parser, argv):
220221
args = parser.parse_args(argv)
221222
if args.version >= 2:
222223
args.function_signature = True
224+
# TODO: This should not be handled differently from the other options
225+
global _verbose, _global_value_regex, _global_hex_value_regex
226+
_verbose = args.verbose
227+
_global_value_regex = args.global_value_regex
228+
_global_hex_value_regex = args.global_hex_value_regex
223229
return args
224230

225231

0 commit comments

Comments
 (0)