[llvm] r367244 - [UpdateTestChecks] Emit warning when invalid value for -check-prefix(es) option
David Bolvansky via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 29 10:41:01 PDT 2019
Author: xbolva00
Date: Mon Jul 29 10:41:00 2019
New Revision: 367244
URL: http://llvm.org/viewvc/llvm-project?rev=367244&view=rev
Log:
[UpdateTestChecks] Emit warning when invalid value for -check-prefix(es) option
Summary:
The script is silent for the following issue:
FileCheck %s -check-prefix=CHECK,POPCOUNT
FileCheck will catch it later, but I think we can warn here too.
Now it warns:
./update_llc_test_checks.py file.ll
WARNING: Supplied prefix 'CHECK,POPCOUNT' is invalid. Prefix must contain only alphanumeric characters, hyphens and underscores. Did you mean --check-prefixes=CHECK,POPCOUNT?
Reviewers: lebedev.ri, spatel, RKSimon, craig.topper, nikic, gbedwell
Reviewed By: RKSimon
Subscribers: llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D64589
Modified:
llvm/trunk/utils/UpdateTestChecks/common.py
llvm/trunk/utils/update_analyze_test_checks.py
llvm/trunk/utils/update_cc_test_checks.py
llvm/trunk/utils/update_llc_test_checks.py
llvm/trunk/utils/update_mca_test_checks.py
llvm/trunk/utils/update_mir_test_checks.py
llvm/trunk/utils/update_test_checks.py
Modified: llvm/trunk/utils/UpdateTestChecks/common.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/UpdateTestChecks/common.py?rev=367244&r1=367243&r2=367244&view=diff
==============================================================================
--- llvm/trunk/utils/UpdateTestChecks/common.py (original)
+++ llvm/trunk/utils/UpdateTestChecks/common.py Mon Jul 29 10:41:00 2019
@@ -47,6 +47,7 @@ def invoke_tool(exe, cmd_args, ir):
RUN_LINE_RE = re.compile('^\s*[;#]\s*RUN:\s*(.*)$')
CHECK_PREFIX_RE = re.compile('--?check-prefix(?:es)?[= ](\S+)')
+PREFIX_RE = re.compile('^[a-zA-Z0-9_-]+$')
CHECK_RE = re.compile(r'^\s*[;#]\s*([^:]+?)(?:-NEXT|-NOT|-DAG|-LABEL)?:')
OPT_FUNCTION_RE = re.compile(
@@ -264,3 +265,27 @@ def add_ir_checks(output_lines, comment_
def add_analyze_checks(output_lines, comment_marker, prefix_list, func_dict, func_name):
check_label_format = '{} %s-LABEL: \'%s\''.format(comment_marker)
add_checks(output_lines, comment_marker, prefix_list, func_dict, func_name, check_label_format, False, True)
+
+
+def check_prefix(prefix):
+ if not PREFIX_RE.match(prefix):
+ hint = ""
+ if ',' in prefix:
+ hint = " Did you mean '--check-prefixes=" + prefix + "'?"
+ print(("WARNING: Supplied prefix '%s' is invalid. Prefix must contain only alphanumeric characters, hyphens and underscores." + hint) %
+ (prefix), file=sys.stderr)
+
+
+def verify_filecheck_prefixes(fc_cmd):
+ fc_cmd_parts = fc_cmd.split()
+ for part in fc_cmd_parts:
+ if "check-prefix=" in part:
+ prefix = part.split('=', 1)[1]
+ check_prefix(prefix)
+ elif "check-prefixes=" in part:
+ prefixes = part.split('=', 1)[1].split(',')
+ for prefix in prefixes:
+ check_prefix(prefix)
+ if prefixes.count(prefix) > 1:
+ print("WARNING: Supplied prefix '%s' is not unique in the prefix list." %
+ (prefix,), file=sys.stderr)
Modified: llvm/trunk/utils/update_analyze_test_checks.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/update_analyze_test_checks.py?rev=367244&r1=367243&r2=367244&view=diff
==============================================================================
--- llvm/trunk/utils/update_analyze_test_checks.py (original)
+++ llvm/trunk/utils/update_analyze_test_checks.py Mon Jul 29 10:41:00 2019
@@ -92,6 +92,7 @@ def main():
prefix_list = []
for l in run_lines:
(tool_cmd, filecheck_cmd) = tuple([cmd.strip() for cmd in l.split('|', 1)])
+ common.verify_filecheck_prefixes(filecheck_cmd)
if not tool_cmd.startswith(opt_basename + ' '):
print('WARNING: Skipping non-%s RUN line: %s' % (opt_basename, l), file=sys.stderr)
Modified: llvm/trunk/utils/update_cc_test_checks.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/update_cc_test_checks.py?rev=367244&r1=367243&r2=367244&view=diff
==============================================================================
--- llvm/trunk/utils/update_cc_test_checks.py (original)
+++ llvm/trunk/utils/update_cc_test_checks.py Mon Jul 29 10:41:00 2019
@@ -168,6 +168,7 @@ def main():
# Extract -check-prefix in FileCheck args
filecheck_cmd = commands[-1]
+ common.verify_filecheck_prefixes(filecheck_cmd)
if not filecheck_cmd.startswith('FileCheck '):
print('WARNING: Skipping non-FileChecked RUN line: ' + l, file=sys.stderr)
continue
Modified: llvm/trunk/utils/update_llc_test_checks.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/update_llc_test_checks.py?rev=367244&r1=367243&r2=367244&view=diff
==============================================================================
--- llvm/trunk/utils/update_llc_test_checks.py (original)
+++ llvm/trunk/utils/update_llc_test_checks.py Mon Jul 29 10:41:00 2019
@@ -89,6 +89,7 @@ def main():
filecheck_cmd = ''
if len(commands) > 1:
filecheck_cmd = commands[1]
+ common.verify_filecheck_prefixes(filecheck_cmd)
if not llc_cmd.startswith('llc '):
print('WARNING: Skipping non-llc RUN line: ' + l, file=sys.stderr)
continue
Modified: llvm/trunk/utils/update_mca_test_checks.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/update_mca_test_checks.py?rev=367244&r1=367243&r2=367244&view=diff
==============================================================================
--- llvm/trunk/utils/update_mca_test_checks.py (original)
+++ llvm/trunk/utils/update_mca_test_checks.py Mon Jul 29 10:41:00 2019
@@ -116,6 +116,7 @@ def _get_run_infos(run_lines, args):
_warn('could not split tool and filecheck commands: {}'.format(run_line))
continue
+ common.verify_filecheck_prefixes(filecheck_cmd)
tool_basename = os.path.splitext(os.path.basename(args.llvm_mca_binary))[0]
if not tool_cmd.startswith(tool_basename + ' '):
Modified: llvm/trunk/utils/update_mir_test_checks.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/update_mir_test_checks.py?rev=367244&r1=367243&r2=367244&view=diff
==============================================================================
--- llvm/trunk/utils/update_mir_test_checks.py (original)
+++ llvm/trunk/utils/update_mir_test_checks.py Mon Jul 29 10:41:00 2019
@@ -122,6 +122,7 @@ def build_run_list(test, run_lines, verb
commands = [cmd.strip() for cmd in l.split('|', 1)]
llc_cmd = commands[0]
filecheck_cmd = commands[1] if len(commands) > 1 else ''
+ common.verify_filecheck_prefixes(filecheck_cmd)
if not llc_cmd.startswith('llc '):
warn('Skipping non-llc RUN line: {}'.format(l), test_file=test)
Modified: llvm/trunk/utils/update_test_checks.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/update_test_checks.py?rev=367244&r1=367243&r2=367244&view=diff
==============================================================================
--- llvm/trunk/utils/update_test_checks.py (original)
+++ llvm/trunk/utils/update_test_checks.py Mon Jul 29 10:41:00 2019
@@ -103,7 +103,7 @@ def main():
prefix_list = []
for l in run_lines:
(tool_cmd, filecheck_cmd) = tuple([cmd.strip() for cmd in l.split('|', 1)])
-
+ common.verify_filecheck_prefixes(filecheck_cmd)
if not tool_cmd.startswith(opt_basename + ' '):
print('WARNING: Skipping non-%s RUN line: %s' % (opt_basename, l), file=sys.stderr)
continue
More information about the llvm-commits
mailing list