[PATCH] D150858: [UpdateTestChecks] Add preprocess_cmd in update_analyze_test_checks.py

Luke Lau via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 18 07:10:49 PDT 2023


luke updated this revision to Diff 523367.
luke added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150858/new/

https://reviews.llvm.org/D150858

Files:
  llvm/utils/update_analyze_test_checks.py


Index: llvm/utils/update_analyze_test_checks.py
===================================================================
--- llvm/utils/update_analyze_test_checks.py
+++ llvm/utils/update_analyze_test_checks.py
@@ -77,7 +77,14 @@
                 common.warn("Skipping unparsable RUN line: " + l)
                 continue
 
-            (tool_cmd, filecheck_cmd) = tuple([cmd.strip() for cmd in l.split("|", 1)])
+            commands = [cmd.strip() for cmd in l.split("|")]
+            assert len(commands) >= 2
+            preprocess_cmd = None
+            if len(commands) > 2:
+                preprocess_cmd = " | ".join(commands[:-2])
+            tool_cmd = commands[-2]
+            filecheck_cmd = commands[-1]
+
             common.verify_filecheck_prefixes(filecheck_cmd)
 
             if not tool_cmd.startswith(opt_basename + " "):
@@ -94,7 +101,7 @@
 
             # FIXME: We should use multiple check prefixes to common check lines. For
             # now, we just ignore all but the last.
-            prefix_list.append((check_prefixes, tool_cmd_args))
+            prefix_list.append((check_prefixes, tool_cmd_args, preprocess_cmd))
 
         builder = common.FunctionTestBuilder(
             run_list=prefix_list,
@@ -113,13 +120,16 @@
             path=ti.path,
         )
 
-        for prefixes, opt_args in prefix_list:
+        for prefixes, opt_args, preprocess_cmd in prefix_list:
             common.debug("Extracted opt cmd:", opt_basename, opt_args, file=sys.stderr)
             common.debug(
                 "Extracted FileCheck prefixes:", str(prefixes), file=sys.stderr
             )
+            common.debug("Extracted preprocess cmd:", preprocess_cmd)
 
-            raw_tool_outputs = common.invoke_tool(ti.args.opt_binary, opt_args, ti.path)
+            raw_tool_outputs = common.invoke_tool(
+                ti.args.opt_binary, opt_args, ti.path, preprocess_cmd
+            )
 
             if re.search(r"Printing analysis ", raw_tool_outputs) is not None:
                 # Split analysis outputs by "Printing analysis " declarations.
@@ -154,7 +164,9 @@
         func_dict = builder.finish_and_get_func_dict()
         is_in_function = False
         is_in_function_start = False
-        prefix_set = set([prefix for prefixes, _ in prefix_list for prefix in prefixes])
+        prefix_set = set(
+            [prefix for prefixes, _, _ in prefix_list for prefix in prefixes]
+        )
         common.debug("Rewriting FileCheck prefixes:", str(prefix_set), file=sys.stderr)
         output_lines = []
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150858.523367.patch
Type: text/x-patch
Size: 2556 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230518/e5eb4864/attachment.bin>


More information about the llvm-commits mailing list