diff --git a/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/x86_asm_mir_mixed.ll b/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/x86_asm_mir_mixed.ll deleted file mode 100644 index 292637177591f..0000000000000 --- a/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/x86_asm_mir_mixed.ll +++ /dev/null @@ -1,17 +0,0 @@ -; RUN: llc -mtriple=x86_64 < %s | FileCheck %s --check-prefix=ASM -; RUN: llc -mtriple=x86_64 -stop-after=finalize-isel < %s | FileCheck %s --check-prefix=MIR - -define i64 @test1(i64 %i) nounwind readnone { - %loc = alloca i64 - %j = load i64, ptr %loc - %r = add i64 %i, %j - ret i64 %r -} - -define i64 @test2(i32 %i) nounwind readnone { - %loc = alloca i32 - %j = load i32, ptr %loc - %r = add i32 %i, %j - %ext = zext i32 %r to i64 - ret i64 %ext -} diff --git a/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/x86_asm_mir_mixed.ll.expected b/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/x86_asm_mir_mixed.ll.expected deleted file mode 100644 index 88cb03e85204a..0000000000000 --- a/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/x86_asm_mir_mixed.ll.expected +++ /dev/null @@ -1,45 +0,0 @@ -; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py -; RUN: llc -mtriple=x86_64 < %s | FileCheck %s --check-prefix=ASM -; RUN: llc -mtriple=x86_64 -stop-after=finalize-isel < %s | FileCheck %s --check-prefix=MIR - -define i64 @test1(i64 %i) nounwind readnone { -; ASM-LABEL: test1: -; ASM: # %bb.0: -; ASM-NEXT: movq %rdi, %rax -; ASM-NEXT: addq -{{[0-9]+}}(%rsp), %rax -; ASM-NEXT: retq -; MIR-LABEL: name: test1 -; MIR: bb.0 (%ir-block.0): -; MIR-NEXT: liveins: $rdi -; MIR-NEXT: {{ $}} -; MIR-NEXT: [[COPY:%[0-9]+]]:gr64 = COPY $rdi -; MIR-NEXT: [[ADD64rm:%[0-9]+]]:gr64 = ADD64rm [[COPY]], %stack.0.loc, 1, $noreg, 0, $noreg, implicit-def dead $eflags :: (dereferenceable load (s64) from %ir.loc) -; MIR-NEXT: $rax = COPY [[ADD64rm]] -; MIR-NEXT: RET 0, $rax - %loc = alloca i64 - %j = load i64, ptr %loc - %r = add i64 %i, %j - ret i64 %r -} - -define i64 @test2(i32 %i) nounwind readnone { -; ASM-LABEL: test2: -; ASM: # %bb.0: -; ASM-NEXT: movl %edi, %eax -; ASM-NEXT: addl -{{[0-9]+}}(%rsp), %eax -; ASM-NEXT: retq -; MIR-LABEL: name: test2 -; MIR: bb.0 (%ir-block.0): -; MIR-NEXT: liveins: $edi -; MIR-NEXT: {{ $}} -; MIR-NEXT: [[COPY:%[0-9]+]]:gr32 = COPY $edi -; MIR-NEXT: [[ADD32rm:%[0-9]+]]:gr32 = ADD32rm [[COPY]], %stack.0.loc, 1, $noreg, 0, $noreg, implicit-def dead $eflags :: (dereferenceable load (s32) from %ir.loc) -; MIR-NEXT: [[SUBREG_TO_REG:%[0-9]+]]:gr64 = SUBREG_TO_REG 0, killed [[ADD32rm]], %subreg.sub_32bit -; MIR-NEXT: $rax = COPY [[SUBREG_TO_REG]] -; MIR-NEXT: RET 0, $rax - %loc = alloca i32 - %j = load i32, ptr %loc - %r = add i32 %i, %j - %ext = zext i32 %r to i64 - ret i64 %ext -} diff --git a/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/x86_asm_mir_same_prefix.ll b/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/x86_asm_mir_same_prefix.ll deleted file mode 100644 index 7167bcf258e68..0000000000000 --- a/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/x86_asm_mir_same_prefix.ll +++ /dev/null @@ -1,13 +0,0 @@ -; RUN: llc -mtriple=x86_64 < %s | FileCheck %s --check-prefix=CHECK -; RUN: llc -mtriple=x86_64 -stop-after=finalize-isel < %s | FileCheck %s --check-prefix=CHECK - -define i32 @add(i32 %a, i32 %b) { - %sum = add i32 %a, %b - ret i32 %sum -} - -define i32 @sub(i32 %a, i32 %b) { - %diff = sub i32 %a, %b - ret i32 %diff -} - diff --git a/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/x86_asm_mir_same_prefix.ll.expected b/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/x86_asm_mir_same_prefix.ll.expected deleted file mode 100644 index 1ba920d1de8b0..0000000000000 --- a/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/x86_asm_mir_same_prefix.ll.expected +++ /dev/null @@ -1,16 +0,0 @@ -; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py -; RUN: llc -mtriple=x86_64 < %s | FileCheck %s --check-prefix=CHECK -; RUN: llc -mtriple=x86_64 -stop-after=finalize-isel < %s | FileCheck %s --check-prefix=CHECK - -define i32 @add(i32 %a, i32 %b) { - %sum = add i32 %a, %b - ret i32 %sum -} - -define i32 @sub(i32 %a, i32 %b) { - %diff = sub i32 %a, %b - ret i32 %diff -} - -;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line: -; CHECK: {{.*}} diff --git a/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/x86-asm-mir-mixed.test b/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/x86-asm-mir-mixed.test deleted file mode 100644 index 6fc57b583b37d..0000000000000 --- a/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/x86-asm-mir-mixed.test +++ /dev/null @@ -1,9 +0,0 @@ -# REQUIRES: x86-registered-target -## Test checking that update_llc_test_checks.py can generate both ASM and MIR checks in the same file - -# RUN: cp -f %S/Inputs/x86_asm_mir_mixed.ll %t.ll && %update_llc_test_checks %t.ll -# RUN: diff -u %S/Inputs/x86_asm_mir_mixed.ll.expected %t.ll - -## Verify that running the script again on an already updated file doesn't add duplicate checks -# RUN: %update_llc_test_checks %t.ll -# RUN: diff -u %S/Inputs/x86_asm_mir_mixed.ll.expected %t.ll diff --git a/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/x86-asm-mir-same-prefix.test b/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/x86-asm-mir-same-prefix.test deleted file mode 100644 index bb91a44678f1a..0000000000000 --- a/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/x86-asm-mir-same-prefix.test +++ /dev/null @@ -1,7 +0,0 @@ -## Test that using the same prefix for both ASM and MIR outputs generates a warning -## and doesn't produce any checks. - -# RUN: cp -f %S/Inputs/x86_asm_mir_same_prefix.ll %t.ll && %update_llc_test_checks %t.ll 2>&1 | FileCheck %s --check-prefix=WARNING -# RUN: diff -u %S/Inputs/x86_asm_mir_same_prefix.ll.expected %t.ll - -# WARNING: WARNING: The following prefixes are used for both ASM and MIR output, which will cause FileCheck failures: CHECK diff --git a/llvm/utils/UpdateTestChecks/common.py b/llvm/utils/UpdateTestChecks/common.py index baa0377cd8b81..2dad16a8eebb7 100644 --- a/llvm/utils/UpdateTestChecks/common.py +++ b/llvm/utils/UpdateTestChecks/common.py @@ -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+") diff --git a/llvm/utils/UpdateTestChecks/mir.py b/llvm/utils/UpdateTestChecks/mir.py index 01ee0e19f7cb9..24bb8b341d335 100644 --- a/llvm/utils/UpdateTestChecks/mir.py +++ b/llvm/utils/UpdateTestChecks/mir.py @@ -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. @@ -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: @@ -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: @@ -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)) diff --git a/llvm/utils/update_llc_test_checks.py b/llvm/utils/update_llc_test_checks.py index 98864be62875b..8c57e75f34f75 100755 --- a/llvm/utils/update_llc_test_checks.py +++ b/llvm/utils/update_llc_test_checks.py @@ -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. @@ -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) @@ -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 @@ -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, @@ -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)) @@ -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 = [] @@ -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: