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

via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 12 01:44:46 PDT 2025


Author: Tomer Shafir
Date: 2025-08-12T11:44:42+03:00
New Revision: d64e6b5e27f78fcf8fe5be4dfa2dcca0ad9af571

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

LOG: [utils][UpdateTestChecks] Warn about possible target triple mismatch (#149645)

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.

Added: 
    llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/target-triple-mismatch.ll
    llvm/test/tools/UpdateTestChecks/update_llc_test_checks/target-triple-mismatch.test

Modified: 
    llvm/utils/UpdateTestChecks/common.py
    llvm/utils/update_llc_test_checks.py

Removed: 
    


################################################################################
diff  --git a/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/target-triple-mismatch.ll b/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/target-triple-mismatch.ll
new file mode 100644
index 0000000000000..3da27cbacd172
--- /dev/null
+++ b/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/target-triple-mismatch.ll
@@ -0,0 +1,7 @@
+; RUN: llc < %s -mtriple=arm64-apple-darwin | FileCheck %s
+
+define i64 @foo(i64 %a) {
+entry:
+  %b = add i64 %a, 1
+  ret i64 %b
+}

diff  --git a/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/target-triple-mismatch.test b/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/target-triple-mismatch.test
new file mode 100644
index 0000000000000..3bbf14d469d4b
--- /dev/null
+++ b/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/target-triple-mismatch.test
@@ -0,0 +1,11 @@
+# REQUIRES: aarch64-registered-target
+## Check that arm64-apple-darwin target triple is wrongly captured as arm64 (non-Apple)
+
+# RUN: cp -f %S/Inputs/target-triple-mismatch.ll %t.ll
+# RUN: %update_llc_test_checks %t.ll 2>&1 | FileCheck %s --check-prefix=LOG
+# RUN: FileCheck --input-file=%t.ll %s --check-prefix=AUTOGEN
+
+# LOG: WARNING: Couldn't match any function. Possibly the wrong target triple has been provided
+
+# AUTOGEN: ;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
+# AUTOGEN-NEXT: ; CHECK: {{.*}}

diff  --git a/llvm/utils/UpdateTestChecks/common.py b/llvm/utils/UpdateTestChecks/common.py
index 178c623e33e0e..a5d4375dc655a 100644
--- a/llvm/utils/UpdateTestChecks/common.py
+++ b/llvm/utils/UpdateTestChecks/common.py
@@ -878,12 +878,17 @@ 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
         )
+        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 +1005,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..8c57e75f34f75 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 0 == 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()


        


More information about the llvm-commits mailing list