Skip to content

Commit 1748e4c

Browse files
committed
Gate the new change with version 7
1 parent cb10fe6 commit 1748e4c

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

@@ -2282,23 +2282,46 @@ def add_checks(
22822282
original_check_lines=original_check_lines.get(checkprefix),
22832283
)
22842284

2285+
# This could be selectively enabled with an optional invocation argument.
2286+
# Disabled for now: better to check everything. Be safe rather than sorry.
2287+
2288+
# Handle the first line of the function body as a special case because
2289+
# it's often just noise (a useless asm comment or entry label).
2290+
# if func_body[0].startswith("#") or func_body[0].startswith("entry:"):
2291+
# is_blank_line = True
2292+
# else:
2293+
# output_lines.append('%s %s: %s' % (comment_marker, checkprefix, func_body[0]))
2294+
# is_blank_line = False
2295+
2296+
is_blank_line = False
22852297

22862298
for func_line in func_body:
22872299
if func_line.strip() == "":
2288-
# Instead of skipping blank lines, using CHECK_EMPTY is more defensive.
2289-
output_lines.append(
2290-
"{} {}-EMPTY:".format(comment_marker, checkprefix)
2291-
)
2300+
if ginfo.get_version() >= 7:
2301+
output_lines.append(
2302+
"{} {}-EMPTY:".format(comment_marker, checkprefix)
2303+
)
2304+
else:
2305+
is_blank_line = True
22922306
continue
22932307
# Do not waste time checking IR comments.
22942308
func_line = SCRUB_IR_COMMENT_RE.sub(r"", func_line)
22952309

2296-
check_suffix = "-NEXT" if not is_filtered else ""
2297-
output_lines.append(
2298-
"{} {}{}: {}".format(
2299-
comment_marker, checkprefix, check_suffix, func_line
2310+
# Skip blank lines instead of checking them.
2311+
if is_blank_line:
2312+
output_lines.append(
2313+
"{} {}: {}".format(
2314+
comment_marker, checkprefix, func_line
2315+
)
23002316
)
2301-
)
2317+
else:
2318+
check_suffix = "-NEXT" if not is_filtered else ""
2319+
output_lines.append(
2320+
"{} {}{}: {}".format(
2321+
comment_marker, checkprefix, check_suffix, func_line
2322+
)
2323+
)
2324+
is_blank_line = False
23022325

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

0 commit comments

Comments
 (0)