diff --git a/llvm/utils/UpdateTestChecks/common.py b/llvm/utils/UpdateTestChecks/common.py --- a/llvm/utils/UpdateTestChecks/common.py +++ b/llvm/utils/UpdateTestChecks/common.py @@ -1142,6 +1142,12 @@ 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() diff --git a/llvm/utils/update_analyze_test_checks.py b/llvm/utils/update_analyze_test_checks.py --- a/llvm/utils/update_analyze_test_checks.py +++ b/llvm/utils/update_analyze_test_checks.py @@ -83,11 +83,7 @@ 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. diff --git a/llvm/utils/update_cc_test_checks.py b/llvm/utils/update_cc_test_checks.py --- a/llvm/utils/update_cc_test_checks.py +++ b/llvm/utils/update_cc_test_checks.py @@ -287,10 +287,7 @@ 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. diff --git a/llvm/utils/update_llc_test_checks.py b/llvm/utils/update_llc_test_checks.py --- a/llvm/utils/update_llc_test_checks.py +++ b/llvm/utils/update_llc_test_checks.py @@ -98,10 +98,7 @@ 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. diff --git a/llvm/utils/update_mca_test_checks.py b/llvm/utils/update_mca_test_checks.py --- a/llvm/utils/update_mca_test_checks.py +++ b/llvm/utils/update_mca_test_checks.py @@ -107,11 +107,7 @@ 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)) diff --git a/llvm/utils/update_mir_test_checks.py b/llvm/utils/update_mir_test_checks.py --- a/llvm/utils/update_mir_test_checks.py +++ b/llvm/utils/update_mir_test_checks.py @@ -135,13 +135,7 @@ 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)) diff --git a/llvm/utils/update_test_checks.py b/llvm/utils/update_test_checks.py --- a/llvm/utils/update_test_checks.py +++ b/llvm/utils/update_test_checks.py @@ -106,12 +106,7 @@ 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.