Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion llvm/utils/UpdateTestChecks/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,6 @@ def invoke_tool(exe, cmd_args, ir, preprocess_cmd=None, verbose=False):
TRIPLE_ARG_RE = re.compile(r"-m?triple[= ]([^ ]+)")
MARCH_ARG_RE = re.compile(r"-march[= ]([^ ]+)")
DEBUG_ONLY_ARG_RE = re.compile(r"-debug-only[= ]([^ ]+)")
STOP_PASS_RE = re.compile(r"-stop-(before|after)=(\w+)")

IS_DEBUG_RECORD_RE = re.compile(r"^(\s+)#dbg_")
IS_SWITCH_CASE_RE = re.compile(r"^\s+i\d+ \d+, label %\S+")
Expand Down
11 changes: 2 additions & 9 deletions llvm/utils/UpdateTestChecks/mir.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,13 @@ def add_mir_checks_for_function(
print_fixed_stack,
first_check_is_next,
at_the_function_name,
check_indent=None,
):
printed_prefixes = set()
for run in run_list:
for prefix in run[0]:
if prefix in printed_prefixes:
break
# func_info can be empty if there was a prefix conflict.
if not func_dict[prefix].get(func_name):
if not func_dict[prefix][func_name]:
continue
if printed_prefixes:
# Add some space between different check prefixes.
Expand All @@ -187,7 +185,6 @@ def add_mir_checks_for_function(
func_dict[prefix][func_name],
print_fixed_stack,
first_check_is_next,
check_indent,
)
break
else:
Expand All @@ -207,7 +204,6 @@ def add_mir_check_lines(
func_info,
print_fixed_stack,
first_check_is_next,
check_indent=None,
):
func_body = str(func_info).splitlines()
if single_bb:
Expand All @@ -224,10 +220,7 @@ def add_mir_check_lines(
first_line = func_body[0]
indent = len(first_line) - len(first_line.lstrip(" "))
# A check comment, indented the appropriate amount
if check_indent is not None:
check = "{}; {}".format(check_indent, prefix)
else:
check = "{:>{}}; {}".format("", indent, prefix)
check = "{:>{}}; {}".format("", indent, prefix)

output_lines.append("{}-LABEL: name: {}".format(check, func_name))

Expand Down
94 changes: 17 additions & 77 deletions llvm/utils/update_llc_test_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import os # Used to advertise this file's name ("autogenerated_note").
import sys

from UpdateTestChecks import common, mir
from UpdateTestChecks import common

# llc is the only llc-like in the LLVM tree but downstream forks can add
# additional ones here if they have them.
Expand All @@ -33,7 +33,6 @@ 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)
Expand All @@ -58,14 +57,9 @@ 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

Expand All @@ -90,7 +84,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.
target_list.append(
run_list.append(
(
check_prefixes,
llc_tool,
Expand Down Expand Up @@ -125,20 +119,14 @@ def update_test(ti: common.TestInfo):
ginfo=ginfo,
)

# 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

for (
prefixes,
llc_tool,
llc_args,
preprocess_cmd,
triple_in_cmd,
march_in_cmd,
) in run_list:
common.debug("Extracted LLC cmd:", llc_tool, llc_args)
common.debug("Extracted FileCheck prefixes:", str(prefixes))

Expand All @@ -153,54 +141,22 @@ def update_test(ti: common.TestInfo):
if not triple:
triple = common.get_triple_from_march(march_in_cmd)

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,
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"
)
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)
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 = []

Expand Down Expand Up @@ -265,22 +221,6 @@ 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:
Expand Down
Loading