Skip to content

Commit 0169a67

Browse files
committed
Gate the new change with version 7
1 parent 80f8e57 commit 0169a67

File tree

3 files changed

+35
-12
lines changed

3 files changed

+35
-12
lines changed

llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/check_empty.ll.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 6
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 7
22
; RUN: opt < %s -S | FileCheck %s
33

44
; Test whether the UTC check empty lines instead of skipping them.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
## test whether the UTC generates CHECK-EMPTY for blank lines
2-
# RUN: cp -f %S/Inputs/check_empty.ll %t.ll && %update_test_checks %t.ll
2+
# RUN: cp -f %S/Inputs/check_empty.ll %t.ll && %update_test_checks %t.ll --version 7
33
# RUN: diff -u %t.ll %S/Inputs/check_empty.ll.expected

llvm/utils/UpdateTestChecks/common.py

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
'none' and 'all'. 'smart' is the default.
3030
5: Basic block labels are matched by FileCheck expressions
3131
6: The semantics of TBAA checks has been incorporated in the check lines.
32-
7: Indent switch-cases correctly.
32+
7: Indent switch-cases correctly; CHECK-EMPTY instead of skipping blank lines.
3333
"""
3434
DEFAULT_VERSION = 6
3535

@@ -2292,24 +2292,47 @@ def add_checks(
22922292
ignore_all_comments=not check_inst_comments,
22932293
)
22942294

2295+
# This could be selectively enabled with an optional invocation argument.
2296+
# Disabled for now: better to check everything. Be safe rather than sorry.
2297+
2298+
# Handle the first line of the function body as a special case because
2299+
# it's often just noise (a useless asm comment or entry label).
2300+
# if func_body[0].startswith("#") or func_body[0].startswith("entry:"):
2301+
# is_blank_line = True
2302+
# else:
2303+
# output_lines.append('%s %s: %s' % (comment_marker, checkprefix, func_body[0]))
2304+
# is_blank_line = False
2305+
2306+
is_blank_line = False
22952307

22962308
for func_line in func_body:
22972309
if func_line.strip() == "":
2298-
# Instead of skipping blank lines, using CHECK_EMPTY is more defensive.
2299-
output_lines.append(
2300-
"{} {}-EMPTY:".format(comment_marker, checkprefix)
2301-
)
2310+
if ginfo.get_version() >= 7:
2311+
output_lines.append(
2312+
"{} {}-EMPTY:".format(comment_marker, checkprefix)
2313+
)
2314+
else:
2315+
is_blank_line = True
23022316
continue
23032317
if not check_inst_comments:
23042318
# Do not waste time checking IR comments unless necessary.
23052319
func_line = SCRUB_IR_COMMENT_RE.sub(r"", func_line)
23062320

2307-
check_suffix = "-NEXT" if not is_filtered else ""
2308-
output_lines.append(
2309-
"{} {}{}: {}".format(
2310-
comment_marker, checkprefix, check_suffix, func_line
2321+
# Skip blank lines instead of checking them.
2322+
if is_blank_line:
2323+
output_lines.append(
2324+
"{} {}: {}".format(
2325+
comment_marker, checkprefix, func_line
2326+
)
23112327
)
2312-
)
2328+
else:
2329+
check_suffix = "-NEXT" if not is_filtered else ""
2330+
output_lines.append(
2331+
"{} {}{}: {}".format(
2332+
comment_marker, checkprefix, check_suffix, func_line
2333+
)
2334+
)
2335+
is_blank_line = False
23132336

23142337
# Add space between different check prefixes and also before the first
23152338
# line of code in the test function.

0 commit comments

Comments
 (0)