[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.
This commit is contained in:
Johannes Doerfert 2023-08-20 16:18:12 -07:00
parent 6ff70ec60e
commit dcd4d0a790
4 changed files with 55 additions and 0 deletions

View File

@ -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
}

View File

@ -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
}

View File

@ -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

View File

@ -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