aboutsummaryrefslogtreecommitdiff
path: root/llvm/utils/UpdateTestChecks/common.py
diff options
context:
space:
mode:
authorJinsong Ji <jinsong.ji@intel.com>2025-02-19 20:29:51 -0500
committerGitHub <noreply@github.com>2025-02-19 20:29:51 -0500
commit5d4998bc02cebd77e70f0fa712ab8e1eb8f643f0 (patch)
treee5c3f8b8b827706d8eb462c67c77df9f1ffc900d /llvm/utils/UpdateTestChecks/common.py
parent007f601f15059520b64c09a32b7bb9d99b845d7e (diff)
downloadllvm-5d4998bc02cebd77e70f0fa712ab8e1eb8f643f0.zip
llvm-5d4998bc02cebd77e70f0fa712ab8e1eb8f643f0.tar.gz
llvm-5d4998bc02cebd77e70f0fa712ab8e1eb8f643f0.tar.bz2
UpdateTestChecks: Don't check meta details in func definition w/--global none (#124205)
When --check-globals none, we skipped all the globals in check lines. However, we are still checking the meta info in function defintion. The generated checks are still sensitive to metadata changes. This is to scrub the meta info and match them with {{.*}} instead.
Diffstat (limited to 'llvm/utils/UpdateTestChecks/common.py')
-rw-r--r--llvm/utils/UpdateTestChecks/common.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/llvm/utils/UpdateTestChecks/common.py b/llvm/utils/UpdateTestChecks/common.py
index 6611dc2..0700486 100644
--- a/llvm/utils/UpdateTestChecks/common.py
+++ b/llvm/utils/UpdateTestChecks/common.py
@@ -983,6 +983,7 @@ class FunctionTestBuilder:
##### Generator of LLVM IR CHECK lines
SCRUB_IR_COMMENT_RE = re.compile(r"\s*;.*")
+SCRUB_IR_FUNC_META_RE = re.compile(r"((?:\!(?!dbg\b)[a-zA-Z_]\w*(?:\s+![0-9]+)?)\s*)+")
# TODO: We should also derive check lines for global, debug, loop declarations, etc..
@@ -1087,6 +1088,7 @@ class GeneralizerInfo:
nameless_values: List[NamelessValue],
regexp_prefix,
regexp_suffix,
+ no_meta_details=False,
):
self._version = version
self._mode = mode
@@ -1094,6 +1096,7 @@ class GeneralizerInfo:
self._regexp_prefix = regexp_prefix
self._regexp_suffix = regexp_suffix
+ self._no_meta_details = no_meta_details
self._regexp, _ = self._build_regexp(False, False)
(
@@ -1147,6 +1150,9 @@ class GeneralizerInfo:
def get_unstable_globals_regexp(self):
return self._unstable_globals_regexp
+ def no_meta_details(self):
+ return self._no_meta_details
+
# The entire match is group 0, the prefix has one group (=1), the entire
# IR_VALUE_REGEXP_STRING is one group (=2), and then the nameless values start.
FIRST_NAMELESS_GROUP_IN_MATCH = 3
@@ -1175,7 +1181,7 @@ class GeneralizerInfo:
return self.get_match_info(match)[1]
-def make_ir_generalizer(version):
+def make_ir_generalizer(version, no_meta_details):
values = []
if version >= 5:
@@ -1224,7 +1230,9 @@ def make_ir_generalizer(version):
# not (unstable_ids_only and nameless_value.match_literally)
# ]
- return GeneralizerInfo(version, GeneralizerInfo.MODE_IR, values, prefix, suffix)
+ return GeneralizerInfo(
+ version, GeneralizerInfo.MODE_IR, values, prefix, suffix, no_meta_details
+ )
def make_asm_generalizer(version):
@@ -1726,6 +1734,7 @@ def generalize_check_lines(
original_check_lines=None,
*,
unstable_globals_only=False,
+ no_meta_details=False,
):
if unstable_globals_only:
regexp = ginfo.get_unstable_globals_regexp()
@@ -1755,6 +1764,9 @@ def generalize_check_lines(
break
# Ignore any comments, since the check lines will too.
scrubbed_line = SCRUB_IR_COMMENT_RE.sub(r"", line)
+ # Ignore the metadata details if check global is none
+ if no_meta_details:
+ scrubbed_line = SCRUB_IR_FUNC_META_RE.sub(r"{{.*}}", scrubbed_line)
lines[i] = scrubbed_line
if not preserve_names:
@@ -1986,6 +1998,7 @@ def add_checks(
global_vars_seen,
preserve_names,
original_check_lines=[],
+ no_meta_details=ginfo.no_meta_details(),
)[0]
func_name_separator = func_dict[checkprefix][func_name].func_name_separator
if "[[" in args_and_sig: