Skip to content

Commit d64e6b5

Browse files
authored
[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.
1 parent 296e057 commit d64e6b5

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
; RUN: llc < %s -mtriple=arm64-apple-darwin | FileCheck %s
2+
3+
define i64 @foo(i64 %a) {
4+
entry:
5+
%b = add i64 %a, 1
6+
ret i64 %b
7+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# REQUIRES: aarch64-registered-target
2+
## Check that arm64-apple-darwin target triple is wrongly captured as arm64 (non-Apple)
3+
4+
# RUN: cp -f %S/Inputs/target-triple-mismatch.ll %t.ll
5+
# RUN: %update_llc_test_checks %t.ll 2>&1 | FileCheck %s --check-prefix=LOG
6+
# RUN: FileCheck --input-file=%t.ll %s --check-prefix=AUTOGEN
7+
8+
# LOG: WARNING: Couldn't match any function. Possibly the wrong target triple has been provided
9+
10+
# AUTOGEN: ;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
11+
# AUTOGEN-NEXT: ; CHECK: {{.*}}

llvm/utils/UpdateTestChecks/common.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -878,12 +878,17 @@ def is_filtered(self):
878878
return False
879879

880880
def process_run_line(self, function_re, scrubber, raw_tool_output, prefixes):
881+
"""
882+
Returns the number of functions processed from the output by the regex.
883+
"""
881884
build_global_values_dictionary(
882885
self._global_var_dict, raw_tool_output, prefixes, self._ginfo
883886
)
887+
processed_func_count = 0
884888
for m in function_re.finditer(raw_tool_output):
885889
if not m:
886890
continue
891+
processed_func_count += 1
887892
func = m.group("func")
888893
body = m.group("body")
889894
# 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):
10001005
# preprocesser directives to exclude individual functions from some
10011006
# RUN lines.
10021007
self._func_dict[prefix][func] = None
1008+
return processed_func_count
10031009

10041010
def processed_prefixes(self, prefixes):
10051011
"""

llvm/utils/update_llc_test_checks.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,12 @@ def update_test(ti: common.TestInfo):
142142
triple = common.get_triple_from_march(march_in_cmd)
143143

144144
scrubber, function_re = output_type.get_run_handler(triple)
145-
builder.process_run_line(function_re, scrubber, raw_tool_output, prefixes)
145+
if 0 == builder.process_run_line(
146+
function_re, scrubber, raw_tool_output, prefixes
147+
):
148+
common.warn(
149+
"Couldn't match any function. Possibly the wrong target triple has been provided"
150+
)
146151
builder.processed_prefixes(prefixes)
147152

148153
func_dict = builder.finish_and_get_func_dict()

0 commit comments

Comments
 (0)