Skip to content

Commit a5d5564

Browse files
committed
UpdateTestChecks: Ignore globals in checks when check-globals is none
1 parent e1aa1e4 commit a5d5564

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

llvm/utils/UpdateTestChecks/common.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,7 @@ def get_failed_prefixes(self):
982982
##### Generator of LLVM IR CHECK lines
983983

984984
SCRUB_IR_COMMENT_RE = re.compile(r"\s*;.*")
985+
SCRUB_IR_FUNC_META_RE = re.compile(r'((?:\!(?!dbg\b)[a-zA-Z_]\w*(?:\s+![0-9]+)?)\s*)+')
985986

986987
# TODO: We should also derive check lines for global, debug, loop declarations, etc..
987988

@@ -1086,13 +1087,15 @@ def __init__(
10861087
nameless_values: List[NamelessValue],
10871088
regexp_prefix,
10881089
regexp_suffix,
1090+
no_meta_details = False
10891091
):
10901092
self._version = version
10911093
self._mode = mode
10921094
self._nameless_values = nameless_values
10931095

10941096
self._regexp_prefix = regexp_prefix
10951097
self._regexp_suffix = regexp_suffix
1098+
self._no_meta_details = no_meta_details
10961099

10971100
self._regexp, _ = self._build_regexp(False, False)
10981101
(
@@ -1146,6 +1149,9 @@ def get_regexp(self):
11461149
def get_unstable_globals_regexp(self):
11471150
return self._unstable_globals_regexp
11481151

1152+
def no_meta_details(self):
1153+
return self._no_meta_details
1154+
11491155
# The entire match is group 0, the prefix has one group (=1), the entire
11501156
# IR_VALUE_REGEXP_STRING is one group (=2), and then the nameless values start.
11511157
FIRST_NAMELESS_GROUP_IN_MATCH = 3
@@ -1174,7 +1180,7 @@ def get_nameless_value_from_match(self, match) -> NamelessValue:
11741180
return self.get_match_info(match)[1]
11751181

11761182

1177-
def make_ir_generalizer(version):
1183+
def make_ir_generalizer(version, no_meta_details):
11781184
values = []
11791185

11801186
if version >= 5:
@@ -1223,7 +1229,7 @@ def make_ir_generalizer(version):
12231229
# not (unstable_ids_only and nameless_value.match_literally)
12241230
# ]
12251231

1226-
return GeneralizerInfo(version, GeneralizerInfo.MODE_IR, values, prefix, suffix)
1232+
return GeneralizerInfo(version, GeneralizerInfo.MODE_IR, values, prefix, suffix, no_meta_details)
12271233

12281234

12291235
def make_asm_generalizer(version):
@@ -1725,6 +1731,7 @@ def generalize_check_lines(
17251731
original_check_lines=None,
17261732
*,
17271733
unstable_globals_only=False,
1734+
no_meta_details = False,
17281735
):
17291736
if unstable_globals_only:
17301737
regexp = ginfo.get_unstable_globals_regexp()
@@ -1754,6 +1761,9 @@ def escape_braces(match_obj):
17541761
break
17551762
# Ignore any comments, since the check lines will too.
17561763
scrubbed_line = SCRUB_IR_COMMENT_RE.sub(r"", line)
1764+
# Ignore the metadata details if check global is none
1765+
if no_meta_details:
1766+
scrubbed_line = SCRUB_IR_FUNC_META_RE.sub(r"{{.*}}", scrubbed_line)
17571767
lines[i] = scrubbed_line
17581768

17591769
if not preserve_names:
@@ -1985,6 +1995,7 @@ def add_checks(
19851995
global_vars_seen,
19861996
preserve_names,
19871997
original_check_lines=[],
1998+
no_meta_details=ginfo.no_meta_details()
19881999
)[0]
19892000
func_name_separator = func_dict[checkprefix][func_name].func_name_separator
19902001
if "[[" in args_and_sig:

llvm/utils/update_cc_test_checks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ def main():
368368

369369
# Store only filechecked runlines.
370370
filecheck_run_list = [i for i in run_list if i[0]]
371-
ginfo = common.make_ir_generalizer(version=ti.args.version)
371+
ginfo = common.make_ir_generalizer(ti.args.version, ti.args.check_globals == "none")
372372
builder = common.FunctionTestBuilder(
373373
run_list=filecheck_run_list,
374374
flags=ti.args,

llvm/utils/update_test_checks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def main():
153153
# now, we just ignore all but the last.
154154
prefix_list.append((check_prefixes, tool_cmd_args, preprocess_cmd))
155155

156-
ginfo = common.make_ir_generalizer(ti.args.version)
156+
ginfo = common.make_ir_generalizer(ti.args.version, ti.args.check_globals == "none")
157157
global_vars_seen_dict = {}
158158
builder = common.FunctionTestBuilder(
159159
run_list=prefix_list,

0 commit comments

Comments
 (0)