Skip to content

Commit da28c33

Browse files
authored
[UTC] Recognise CHECK lines with globals matched literally (#70050)
Previously when using `-p` a.k.a. `--preserve-names` existing lines for checking globals were not recognised as such, leading to the line being kept while also being emitted again, resulting in duplicated CHECK lines. This resolves #70048.
1 parent a1b2ace commit da28c33

File tree

4 files changed

+35
-1
lines changed

4 files changed

+35
-1
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
; RUN: opt -S < %s | FileCheck %s
2+
3+
@G = constant i32 42
4+
5+
;.
6+
; CHECK: @G = constant i32 42
7+
;.
8+
define ptr @foo() {
9+
; CHECK-LABEL: @foo(
10+
; CHECK-NEXT: ret ptr @G
11+
;
12+
ret ptr @G
13+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: -p --check-globals
2+
; RUN: opt -S < %s | FileCheck %s
3+
4+
@G = constant i32 42
5+
6+
;.
7+
; CHECK: @G = constant i32 42
8+
;.
9+
define ptr @foo() {
10+
; CHECK-LABEL: @foo(
11+
; CHECK-NEXT: ret ptr @G
12+
;
13+
ret ptr @G
14+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## Basic test checking that we capture existing lines matching global variable names
2+
# RUN: cp -f %S/Inputs/global_preserve_name.ll %t.ll && %update_test_checks %t.ll --check-globals --preserve-names
3+
# RUN: diff -u %t.ll %S/Inputs/global_preserve_name.ll.expected
4+
## Verify that running without the --global-value-regex flag respects UTC_ARGS, and that the output is a fixed point.
5+
# RUN: %update_test_checks %t.ll
6+
# RUN: diff -u %t.ll %S/Inputs/global_preserve_name.ll.expected
7+

llvm/utils/UpdateTestChecks/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ def should_add_line_to_output(
391391
m = CHECK_RE.match(input_line)
392392
if m and m.group(1) in prefix_set:
393393
if skip_global_checks:
394-
global_ir_value_re = re.compile(r"\[\[", flags=(re.M))
394+
global_ir_value_re = re.compile(r"(\[\[|@)", flags=(re.M))
395395
return not global_ir_value_re.search(input_line)
396396
return False
397397

0 commit comments

Comments
 (0)