[llvm] [utils][UpdateTestChecks] Warn about possible target triple mismatch (PR #149645)

Tomer Shafir via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 11 05:57:36 PDT 2025


https://github.com/tomershafir updated https://github.com/llvm/llvm-project/pull/149645

>From 19d41ca66effde49f18c20b698574c508ad4e025 Mon Sep 17 00:00:00 2001
From: tomershafir <tomer.shafir8 at gmail.com>
Date: Sat, 19 Jul 2025 11:26:48 +0300
Subject: [PATCH 1/2] [utils][UpdateTestChecks] Warn about possible target
 triple mismatch

Aims to improve error reporting by printing a warning if the target function regex that has been selected finds no matches. For example, a `-mtriple=arm64-apple-darwin` runline, would map to the `arm64` prefix by `update_llc_test_checks.py` and wouldn't match Apple's function layout, generating some not understandable garbage checks.

The implementation changes `common.process_run_line` to return an abstract indicator of number of functions processed, without breaking the drivers. Then `update_llc_test_checks.py` prints a driver specific error message.
---
 llvm/utils/UpdateTestChecks/common.py | 3 +++
 llvm/utils/update_llc_test_checks.py  | 7 ++++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/llvm/utils/UpdateTestChecks/common.py b/llvm/utils/UpdateTestChecks/common.py
index 178c623e33e0e..74311770c6b35 100644
--- a/llvm/utils/UpdateTestChecks/common.py
+++ b/llvm/utils/UpdateTestChecks/common.py
@@ -881,9 +881,11 @@ def process_run_line(self, function_re, scrubber, raw_tool_output, prefixes):
         build_global_values_dictionary(
             self._global_var_dict, raw_tool_output, prefixes, self._ginfo
         )
+        processed_func_count = 0
         for m in function_re.finditer(raw_tool_output):
             if not m:
                 continue
+            processed_func_count += 1
             func = m.group("func")
             body = m.group("body")
             # func_name_separator is the string that is placed right after function name at the
@@ -1000,6 +1002,7 @@ def process_run_line(self, function_re, scrubber, raw_tool_output, prefixes):
                         # preprocesser directives to exclude individual functions from some
                         # RUN lines.
                         self._func_dict[prefix][func] = None
+        return processed_func_count
 
     def processed_prefixes(self, prefixes):
         """
diff --git a/llvm/utils/update_llc_test_checks.py b/llvm/utils/update_llc_test_checks.py
index 07216d7dbfbb2..e5aa555e1e1ee 100755
--- a/llvm/utils/update_llc_test_checks.py
+++ b/llvm/utils/update_llc_test_checks.py
@@ -142,7 +142,12 @@ def update_test(ti: common.TestInfo):
             triple = common.get_triple_from_march(march_in_cmd)
 
         scrubber, function_re = output_type.get_run_handler(triple)
-        builder.process_run_line(function_re, scrubber, raw_tool_output, prefixes)
+        if not builder.process_run_line(
+            function_re, scrubber, raw_tool_output, prefixes
+        ):
+            common.warn(
+                "Couldn't match any function. Possibly the wrong target triple has been provided"
+            )
         builder.processed_prefixes(prefixes)
 
     func_dict = builder.finish_and_get_func_dict()

>From 53da32f58a02466b950bb55fb12a38d411a9bc6b Mon Sep 17 00:00:00 2001
From: tomershafir <tomer.shafir8 at gmail.com>
Date: Mon, 11 Aug 2025 15:57:02 +0300
Subject: [PATCH 2/2] document process_run_line and check 0== instead not

---
 llvm/utils/UpdateTestChecks/common.py | 3 +++
 llvm/utils/update_llc_test_checks.py  | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/llvm/utils/UpdateTestChecks/common.py b/llvm/utils/UpdateTestChecks/common.py
index 74311770c6b35..a5d4375dc655a 100644
--- a/llvm/utils/UpdateTestChecks/common.py
+++ b/llvm/utils/UpdateTestChecks/common.py
@@ -878,6 +878,9 @@ def is_filtered(self):
         return False
 
     def process_run_line(self, function_re, scrubber, raw_tool_output, prefixes):
+        """
+        Returns the number of functions processed from the output by the regex.
+        """
         build_global_values_dictionary(
             self._global_var_dict, raw_tool_output, prefixes, self._ginfo
         )
diff --git a/llvm/utils/update_llc_test_checks.py b/llvm/utils/update_llc_test_checks.py
index e5aa555e1e1ee..8c57e75f34f75 100755
--- a/llvm/utils/update_llc_test_checks.py
+++ b/llvm/utils/update_llc_test_checks.py
@@ -142,7 +142,7 @@ def update_test(ti: common.TestInfo):
             triple = common.get_triple_from_march(march_in_cmd)
 
         scrubber, function_re = output_type.get_run_handler(triple)
-        if not builder.process_run_line(
+        if 0 == builder.process_run_line(
             function_re, scrubber, raw_tool_output, prefixes
         ):
             common.warn(



More information about the llvm-commits mailing list