aboutsummaryrefslogtreecommitdiff
path: root/llvm/utils/update_llc_test_checks.py
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/utils/update_llc_test_checks.py')
-rwxr-xr-xllvm/utils/update_llc_test_checks.py94
1 files changed, 77 insertions, 17 deletions
diff --git a/llvm/utils/update_llc_test_checks.py b/llvm/utils/update_llc_test_checks.py
index 8c57e75..98864be 100755
--- a/llvm/utils/update_llc_test_checks.py
+++ b/llvm/utils/update_llc_test_checks.py
@@ -15,7 +15,7 @@ import argparse
import os # Used to advertise this file's name ("autogenerated_note").
import sys
-from UpdateTestChecks import common
+from UpdateTestChecks import common, mir
# llc is the only llc-like in the LLVM tree but downstream forks can add
# additional ones here if they have them.
@@ -33,6 +33,7 @@ def update_test(ti: common.TestInfo):
break
run_list = []
+ mir_run_list = []
for l in ti.run_lines:
if "|" not in l:
common.warn("Skipping unparsable RUN line: " + l)
@@ -57,9 +58,14 @@ def update_test(ti: common.TestInfo):
if m:
march_in_cmd = m.groups()[0]
+ target_list = run_list
m = common.DEBUG_ONLY_ARG_RE.search(llc_cmd)
if m and m.groups()[0] == "isel":
from UpdateTestChecks import isel as output_type
+ elif not m and common.STOP_PASS_RE.search(llc_cmd):
+ # MIR output mode. If -debug-only is present assume
+ # the debug output is the main point of interest.
+ target_list = mir_run_list
else:
from UpdateTestChecks import asm as output_type
@@ -84,7 +90,7 @@ def update_test(ti: common.TestInfo):
# FIXME: We should use multiple check prefixes to common check lines. For
# now, we just ignore all but the last.
- run_list.append(
+ target_list.append(
(
check_prefixes,
llc_tool,
@@ -119,14 +125,20 @@ def update_test(ti: common.TestInfo):
ginfo=ginfo,
)
- for (
- prefixes,
- llc_tool,
- llc_args,
- preprocess_cmd,
- triple_in_cmd,
- march_in_cmd,
- ) in run_list:
+ # Dictionary to store MIR function bodies separately
+ mir_func_dict = {}
+ for run_tuple, is_mir in [(run, False) for run in run_list] + [
+ (run, True) for run in mir_run_list
+ ]:
+ (
+ prefixes,
+ llc_tool,
+ llc_args,
+ preprocess_cmd,
+ triple_in_cmd,
+ march_in_cmd,
+ ) = run_tuple
+
common.debug("Extracted LLC cmd:", llc_tool, llc_args)
common.debug("Extracted FileCheck prefixes:", str(prefixes))
@@ -141,22 +153,54 @@ def update_test(ti: common.TestInfo):
if not triple:
triple = common.get_triple_from_march(march_in_cmd)
- scrubber, function_re = output_type.get_run_handler(triple)
- 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"
+ if is_mir:
+ # MIR output mode
+ common.debug("Detected MIR output mode for prefixes:", str(prefixes))
+ for prefix in prefixes:
+ if prefix not in mir_func_dict:
+ mir_func_dict[prefix] = {}
+
+ mir.build_function_info_dictionary(
+ ti.path,
+ raw_tool_output,
+ triple,
+ prefixes,
+ mir_func_dict,
+ ti.args.verbose,
)
- builder.processed_prefixes(prefixes)
+ else:
+ # ASM output mode
+ scrubber, function_re = output_type.get_run_handler(triple)
+ 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()
+
+ # Check for conflicts: same prefix used for both ASM and MIR
+ conflicting_prefixes = set(func_dict.keys()) & set(mir_func_dict.keys())
+ if conflicting_prefixes:
+ common.warn(
+ "The following prefixes are used for both ASM and MIR output, which will cause FileCheck failures: {}".format(
+ ", ".join(sorted(conflicting_prefixes))
+ ),
+ test_file=ti.path,
+ )
+ for prefix in conflicting_prefixes:
+ mir_func_dict[prefix] = {}
+ func_dict[prefix] = {}
+
global_vars_seen_dict = {}
is_in_function = False
is_in_function_start = False
func_name = None
prefix_set = set([prefix for p in run_list for prefix in p[0]])
+ prefix_set.update([prefix for p in mir_run_list for prefix in p[0]])
common.debug("Rewriting FileCheck prefixes:", str(prefix_set))
output_lines = []
@@ -221,6 +265,22 @@ def update_test(ti: common.TestInfo):
is_filtered=builder.is_filtered(),
)
)
+
+ # Also add MIR checks if we have them for this function
+ if mir_run_list and func_name:
+ mir.add_mir_checks_for_function(
+ ti.path,
+ output_lines,
+ mir_run_list,
+ mir_func_dict,
+ func_name,
+ single_bb=False, # Don't skip basic block labels.
+ print_fixed_stack=False, # Don't print fixed stack (ASM tests don't need it).
+ first_check_is_next=False, # First check is LABEL, not NEXT.
+ at_the_function_name=False, # Use "name:" not "@name".
+ check_indent="", # No indentation for IR files (not MIR files).
+ )
+
is_in_function_start = False
if is_in_function: