Skip to content

Commit 84c368e

Browse files
committedSep 18, 2019
[utils] Add minimal support for MIR inputs to update_llc_test_checks.py
update_{llc,mir}_test_checks.py applicability is determined by the output (assembly or MIR), not the input, which makes update_llc_test_checks.py the right tool to generate tests that start at MIR and stop at the final assembly. This commit adds the minimal support for this path. Main limitation that remains: - MIR has to have LLVM IR section, and the CHECK lines will be inserted into the LLVM IR functions that correspond to the MIR functions. Running ../utils/update_llc_test_checks.py --llc-binary ./bin/llc on a slightly modified ../test/CodeGen/X86/bad-tls-fold.mir produces the following diff: +# NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +# RUN: llc %s -o - | FileCheck %s --- | target triple = "x86_64-unknown-linux-gnu" @@ -6,17 +7,31 @@ @i = external thread_local global i32 define i32 @or() { + ; CHECK-LABEL: or: + ; CHECK: # %bb.0: # %entry + ; CHECK-NEXT: movq {{.*}}(%rip), %rax + ; CHECK-NEXT: orq $7, %rax + ; CHECK-NEXT: movq i@{{.*}}(%rip), %rcx + ; CHECK-NEXT: orq %rax, %rcx + ; CHECK-NEXT: movl %fs:(%rcx), %eax + ; CHECK-NEXT: retq entry: ret i32 undef } - define i32 @and() { + ; CHECK-LABEL: and: + ; CHECK: # %bb.0: # %entry + ; CHECK-NEXT: movq {{.*}}(%rip), %rax + ; CHECK-NEXT: orq $7, %rax + ; CHECK-NEXT: movq i@{{.*}}(%rip), %rcx + ; CHECK-NEXT: andq %rax, %rcx + ; CHECK-NEXT: movl %fs:(%rcx), %eax + ; CHECK-NEXT: retq entry: ret i32 undef } ... (not applied) llvm-svn: 372277
1 parent 73778e9 commit 84c368e

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed
 

‎llvm/utils/update_llc_test_checks.py

+12-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
from UpdateTestChecks import asm, common
2121

22-
ADVERT = '; NOTE: Assertions have been autogenerated by '
22+
ADVERT = ' NOTE: Assertions have been autogenerated by '
2323

2424

2525
def main():
@@ -44,7 +44,6 @@ def main():
4444
args = parser.parse_args()
4545

4646
script_name = os.path.basename(__file__)
47-
autogenerated_note = (ADVERT + 'utils/' + script_name)
4847

4948
test_paths = [test for pattern in args.tests for test in glob.glob(pattern)]
5049
for test in test_paths:
@@ -118,6 +117,13 @@ def main():
118117

119118
llc_cmd_args = llc_cmd[len(llc_tool):].strip()
120119
llc_cmd_args = llc_cmd_args.replace('< %s', '').replace('%s', '').strip()
120+
if test.endswith('.mir'):
121+
llc_cmd_args += ' -x mir'
122+
comment_sym = '#'
123+
check_indent = ' '
124+
else:
125+
comment_sym = ';'
126+
check_indent = ''
121127

122128
check_prefixes = [item for m in common.CHECK_PREFIX_RE.finditer(filecheck_cmd)
123129
for item in m.group(1).split(',')]
@@ -128,6 +134,8 @@ def main():
128134
# now, we just ignore all but the last.
129135
run_list.append((check_prefixes, llc_cmd_args, triple_in_cmd, march_in_cmd))
130136

137+
autogenerated_note = (comment_sym + ADVERT + 'utils/' + script_name)
138+
131139
func_dict = {}
132140
for p in run_list:
133141
prefixes = p[0]
@@ -166,7 +174,7 @@ def main():
166174
continue
167175

168176
# Print out the various check lines here.
169-
asm.add_asm_checks(output_lines, ';', run_list, func_dict, func_name)
177+
asm.add_asm_checks(output_lines, check_indent + ';', run_list, func_dict, func_name)
170178
is_in_function_start = False
171179

172180
if is_in_function:
@@ -180,7 +188,7 @@ def main():
180188
continue
181189

182190
# Discard any previous script advertising.
183-
if input_line.startswith(ADVERT):
191+
if input_line.startswith(comment_sym + ADVERT):
184192
continue
185193

186194
# If it's outside a function, it just gets copied to the output.

0 commit comments

Comments
 (0)
Please sign in to comment.