[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 04:05:18 PDT 2023


luke created this revision.
luke added reviewers: RKSimon, pengfei, MaskRay, lebedev.ri.
Herald added subscribers: asb, luismarques, pmatos, StephenFan.
Herald added a project: All.
luke requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Similar to how update_llc_test_checks.py and update_test_checks.py, this
allows a sed command or similar to be used to preprocess an analysis
test.
This code was copied straight from update_llc_test_checks, and could
probably be shared.


Repository:
  rG LLVM Github Monorepo

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
@@ -70,7 +70,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 + ' '):
@@ -87,7 +94,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,
@@ -100,11 +107,12 @@
       scrubber_args = [],
       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.
@@ -125,7 +133,7 @@
     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.523329.patch
Type: text/x-patch
Size: 2287 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230518/64f9904f/attachment.bin>


More information about the llvm-commits mailing list