[llvm] [NFC][UTC] Avoid copy-paste in `update_analyze_test_checks.py` (PR #178456)

Andrei Elovikov via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 28 08:47:33 PST 2026


https://github.com/eas updated https://github.com/llvm/llvm-project/pull/178456

>From 5f30904bb9139e92c7d7afb40601baeb26b47d30 Mon Sep 17 00:00:00 2001
From: Andrei Elovikov <andrei.elovikov at sifive.com>
Date: Tue, 27 Jan 2026 17:00:28 -0800
Subject: [PATCH 1/2] [NFC][UTC] Avoid copy-paste in
 `update_analyze_test_checks.py`

I'm going to extend it to support VPlan dump tests soon and this cleanup
avoids future growth of the `if/elif/elif` chain.
---
 llvm/utils/update_analyze_test_checks.py | 30 +++++++++---------------
 1 file changed, 11 insertions(+), 19 deletions(-)

diff --git a/llvm/utils/update_analyze_test_checks.py b/llvm/utils/update_analyze_test_checks.py
index 3f14452767f9e..9eca0075567ca 100755
--- a/llvm/utils/update_analyze_test_checks.py
+++ b/llvm/utils/update_analyze_test_checks.py
@@ -99,30 +99,22 @@ def update_test(opt_basename: str, ti: common.TestInfo):
 
         raw_tool_outputs = common.invoke_tool(ti.args.opt_binary, opt_args, ti.path)
 
-        if re.search(r"Printing analysis ", raw_tool_outputs) is not None:
-            # Split analysis outputs by "Printing analysis " declarations.
-            for raw_tool_output in re.split(r"Printing analysis ", raw_tool_outputs):
-                builder.process_run_line(
-                    common.ANALYZE_FUNCTION_RE,
-                    common.scrub_body,
-                    raw_tool_output,
-                    prefixes,
-                )
-        elif (
-            re.search(
-                r"(LV|LDist|HashRecognize): Checking a loop in ", raw_tool_outputs
-            )
-            is not None
-        ):
-            for raw_tool_output in re.split(
-                r"(LV|LDist|HashRecognize): Checking a loop in ", raw_tool_outputs
-            ):
+        regex_map = {
+            r"Printing analysis ": common.ANALYZE_FUNCTION_RE,
+            r"(LV|LDist|HashRecognize): Checking a loop in " : common.LOOP_PASS_DEBUG_RE,
+        }
+
+        for split_by, regex in regex_map.items():
+            if re.search(split_by, raw_tool_outputs) is None:
+                continue
+            for raw_tool_output in re.split(split_by, raw_tool_outputs):
                 builder.process_run_line(
-                    common.LOOP_PASS_DEBUG_RE,
+                    regex,
                     common.scrub_body,
                     raw_tool_output,
                     prefixes,
                 )
+            break
         else:
             common.warn("Don't know how to deal with this output")
             continue

>From d522f1b2c355858fc6887be0e6d873f788638497 Mon Sep 17 00:00:00 2001
From: Andrei Elovikov <andrei.elovikov at sifive.com>
Date: Wed, 28 Jan 2026 08:47:12 -0800
Subject: [PATCH 2/2] Fix formatting

---
 llvm/utils/update_analyze_test_checks.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/utils/update_analyze_test_checks.py b/llvm/utils/update_analyze_test_checks.py
index 9eca0075567ca..fa287110053e2 100755
--- a/llvm/utils/update_analyze_test_checks.py
+++ b/llvm/utils/update_analyze_test_checks.py
@@ -101,7 +101,7 @@ def update_test(opt_basename: str, ti: common.TestInfo):
 
         regex_map = {
             r"Printing analysis ": common.ANALYZE_FUNCTION_RE,
-            r"(LV|LDist|HashRecognize): Checking a loop in " : common.LOOP_PASS_DEBUG_RE,
+            r"(LV|LDist|HashRecognize): Checking a loop in ": common.LOOP_PASS_DEBUG_RE,
         }
 
         for split_by, regex in regex_map.items():



More information about the llvm-commits mailing list