[UpdateTestChecks][NFC] Share the code to get CHECK prefix between all scripts

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D143307
This commit is contained in:
Shengchen Kan 2023-02-04 09:35:32 +08:00
parent abbd4da204
commit ae691c3812
7 changed files with 12 additions and 31 deletions

View File

@ -1142,6 +1142,12 @@ def check_prefix(prefix):
warn(("Supplied prefix '%s' is invalid. Prefix must contain only alphanumeric characters, hyphens and underscores." + hint) %
(prefix))
def get_check_prefixes(filecheck_cmd):
check_prefixes = [item for m in CHECK_PREFIX_RE.finditer(filecheck_cmd)
for item in m.group(1).split(',')]
if not check_prefixes:
check_prefixes = ['CHECK']
return check_prefixes
def verify_filecheck_prefixes(fc_cmd):
fc_cmd_parts = fc_cmd.split()

View File

@ -83,11 +83,7 @@ def main():
tool_cmd_args = tool_cmd[len(opt_basename):].strip()
tool_cmd_args = tool_cmd_args.replace('< %s', '').replace('%s', '').strip()
check_prefixes = [item for m in common.CHECK_PREFIX_RE.finditer(filecheck_cmd)
for item in m.group(1).split(',')]
if not check_prefixes:
check_prefixes = ['CHECK']
check_prefixes = common.get_check_prefixes(filecheck_cmd)
# FIXME: We should use multiple check prefixes to common check lines. For
# now, we just ignore all but the last.

View File

@ -287,10 +287,7 @@ def main():
run_list.append((None, exe, None, None))
continue
check_prefixes = [item for m in common.CHECK_PREFIX_RE.finditer(filecheck_cmd)
for item in m.group(1).split(',')]
if not check_prefixes:
check_prefixes = ['CHECK']
check_prefixes = common.get_check_prefixes(filecheck_cmd)
run_list.append((check_prefixes, clang_args, commands[1:-1], triple_in_cmd))
# Execute clang, generate LLVM IR, and extract functions.

View File

@ -98,10 +98,7 @@ def main():
llc_cmd_args = llc_cmd_args.replace('< %s', '').replace('%s', '').strip()
if ti.path.endswith('.mir'):
llc_cmd_args += ' -x mir'
check_prefixes = [item for m in common.CHECK_PREFIX_RE.finditer(filecheck_cmd)
for item in m.group(1).split(',')]
if not check_prefixes:
check_prefixes = ['CHECK']
check_prefixes = common.get_check_prefixes(filecheck_cmd)
# FIXME: We should use multiple check prefixes to common check lines. For
# now, we just ignore all but the last.

View File

@ -107,11 +107,7 @@ def _get_run_infos(run_lines, args):
tool_cmd_args = tool_cmd[len(tool_basename):].strip()
tool_cmd_args = tool_cmd_args.replace('< %s', '').replace('%s', '').strip()
check_prefixes = [item
for m in common.CHECK_PREFIX_RE.finditer(filecheck_cmd)
for item in m.group(1).split(',')]
if not check_prefixes:
check_prefixes = ['CHECK']
check_prefixes = common.get_check_prefixes(filecheck_cmd)
run_infos.append((check_prefixes, tool_cmd_args))

View File

@ -135,13 +135,7 @@ def build_run_list(test, run_lines, verbose=False):
cmd_args = llc_cmd[len('llc'):].strip()
cmd_args = cmd_args.replace('< %s', '').replace('%s', '').strip()
check_prefixes = [
item
for m in common.CHECK_PREFIX_RE.finditer(filecheck_cmd)
for item in m.group(1).split(',')]
if not check_prefixes:
check_prefixes = ['CHECK']
check_prefixes = common.get_check_prefixes(filecheck_cmd)
all_prefixes += check_prefixes
run_list.append(Run(check_prefixes, cmd_args, triple))

View File

@ -106,12 +106,7 @@ def main():
tool_cmd_args = tool_cmd[len(tool_basename):].strip()
tool_cmd_args = tool_cmd_args.replace('< %s', '').replace('%s', '').strip()
check_prefixes = [item for m in
common.CHECK_PREFIX_RE.finditer(filecheck_cmd)
for item in m.group(1).split(',')]
if not check_prefixes:
check_prefixes = ['CHECK']
check_prefixes = common.get_check_prefixes(filecheck_cmd)
# FIXME: We should use multiple check prefixes to common check lines. For
# now, we just ignore all but the last.