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 000000000000..3da27cbacd17 --- /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 000000000000..3bbf14d469d4 --- /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 178c623e33e0..a5d4375dc655 100644 --- a/llvm/utils/UpdateTestChecks/common.py +++ b/llvm/utils/UpdateTestChecks/common.py @@ -878,12 +878,17 @@ class FunctionTestBuilder: 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 @@ class FunctionTestBuilder: # 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 07216d7dbfbb..8c57e75f34f7 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()