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

Shengchen Kan via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 3 18:44:19 PST 2023


Author: Shengchen Kan
Date: 2023-02-04T10:44:14+08:00
New Revision: ae691c381261311c4ae2697fc5b1ae2e2113ca6c

URL: https://github.com/llvm/llvm-project/commit/ae691c381261311c4ae2697fc5b1ae2e2113ca6c
DIFF: https://github.com/llvm/llvm-project/commit/ae691c381261311c4ae2697fc5b1ae2e2113ca6c.diff

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

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D143307

Added: 
    

Modified: 
    llvm/utils/UpdateTestChecks/common.py
    llvm/utils/update_analyze_test_checks.py
    llvm/utils/update_cc_test_checks.py
    llvm/utils/update_llc_test_checks.py
    llvm/utils/update_mca_test_checks.py
    llvm/utils/update_mir_test_checks.py
    llvm/utils/update_test_checks.py

Removed: 
    


################################################################################
diff  --git a/llvm/utils/UpdateTestChecks/common.py b/llvm/utils/UpdateTestChecks/common.py
index 7e538d775efa7..b35fac4c4817a 100644
--- a/llvm/utils/UpdateTestChecks/common.py
+++ b/llvm/utils/UpdateTestChecks/common.py
@@ -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()

diff  --git a/llvm/utils/update_analyze_test_checks.py b/llvm/utils/update_analyze_test_checks.py
index ed2d5d455271d..0e19bd22d926b 100755
--- a/llvm/utils/update_analyze_test_checks.py
+++ b/llvm/utils/update_analyze_test_checks.py
@@ -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.

diff  --git a/llvm/utils/update_cc_test_checks.py b/llvm/utils/update_cc_test_checks.py
index a2e954a677f1f..5b6ce0d629e4a 100755
--- a/llvm/utils/update_cc_test_checks.py
+++ b/llvm/utils/update_cc_test_checks.py
@@ -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.

diff  --git a/llvm/utils/update_llc_test_checks.py b/llvm/utils/update_llc_test_checks.py
index f9e205155f3eb..3744788b927d7 100755
--- a/llvm/utils/update_llc_test_checks.py
+++ b/llvm/utils/update_llc_test_checks.py
@@ -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.

diff  --git a/llvm/utils/update_mca_test_checks.py b/llvm/utils/update_mca_test_checks.py
index c5798a3a8848e..db4511dac7c02 100755
--- a/llvm/utils/update_mca_test_checks.py
+++ b/llvm/utils/update_mca_test_checks.py
@@ -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))
 

diff  --git a/llvm/utils/update_mir_test_checks.py b/llvm/utils/update_mir_test_checks.py
index 21f3f779b0932..6e3a5e9732761 100755
--- a/llvm/utils/update_mir_test_checks.py
+++ b/llvm/utils/update_mir_test_checks.py
@@ -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))

diff  --git a/llvm/utils/update_test_checks.py b/llvm/utils/update_test_checks.py
index c3d8ef87ffef1..2a5ecc67ed1e5 100755
--- a/llvm/utils/update_test_checks.py
+++ b/llvm/utils/update_test_checks.py
@@ -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.


        


More information about the llvm-commits mailing list