[llvm] r372277 - [utils] Add minimal support for MIR inputs to update_llc_test_checks.py

Roman Tereshin via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 19 06:52:37 PDT 2019


Hi Roman,

> Was this reviewed?

On Phabricator - no, internally - yes (+ Justin).

> The patch description does not mention utils/update_mir_test_checks.py

Not sure what do you mean:
1. The patch description does mention utils/update_mir_test_checks.py, though in the passing: "update_{llc,mir}_test_checks.py applicability is ...”
2. The patch does not change utils/update_mir_test_checks.py, it only changes utils/update_llc_test_checks.py

Is there any problem with the patch?

Thanks,
Roman

> On Sep 19, 2019, at 1:06 AM, Roman Lebedev <lebedev.ri at gmail.com> wrote:
> 
> Was this reviewed?
> The patch description does not mention utils/update_mir_test_checks.py
> 
> On Thu, Sep 19, 2019 at 2:42 AM Roman Tereshin via llvm-commits
> <llvm-commits at lists.llvm.org> wrote:
>> 
>> Author: rtereshin
>> Date: Wed Sep 18 16:44:17 2019
>> New Revision: 372277
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=372277&view=rev
>> Log:
>> [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)
>> 
>> Modified:
>>    llvm/trunk/utils/update_llc_test_checks.py
>> 
>> Modified: llvm/trunk/utils/update_llc_test_checks.py
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/update_llc_test_checks.py?rev=372277&r1=372276&r2=372277&view=diff
>> ==============================================================================
>> --- llvm/trunk/utils/update_llc_test_checks.py (original)
>> +++ llvm/trunk/utils/update_llc_test_checks.py Wed Sep 18 16:44:17 2019
>> @@ -19,7 +19,7 @@ import re
>> 
>> from UpdateTestChecks import asm, common
>> 
>> -ADVERT = '; NOTE: Assertions have been autogenerated by '
>> +ADVERT = ' NOTE: Assertions have been autogenerated by '
>> 
>> 
>> def main():
>> @@ -44,7 +44,6 @@ def main():
>>   args = parser.parse_args()
>> 
>>   script_name = os.path.basename(__file__)
>> -  autogenerated_note = (ADVERT + 'utils/' + script_name)
>> 
>>   test_paths = [test for pattern in args.tests for test in glob.glob(pattern)]
>>   for test in test_paths:
>> @@ -118,6 +117,13 @@ def main():
>> 
>>       llc_cmd_args = llc_cmd[len(llc_tool):].strip()
>>       llc_cmd_args = llc_cmd_args.replace('< %s', '').replace('%s', '').strip()
>> +      if test.endswith('.mir'):
>> +        llc_cmd_args += ' -x mir'
>> +        comment_sym = '#'
>> +        check_indent = '  '
>> +      else:
>> +        comment_sym = ';'
>> +        check_indent = ''
>> 
>>       check_prefixes = [item for m in common.CHECK_PREFIX_RE.finditer(filecheck_cmd)
>>                                for item in m.group(1).split(',')]
>> @@ -128,6 +134,8 @@ def main():
>>       # now, we just ignore all but the last.
>>       run_list.append((check_prefixes, llc_cmd_args, triple_in_cmd, march_in_cmd))
>> 
>> +    autogenerated_note = (comment_sym + ADVERT + 'utils/' + script_name)
>> +
>>     func_dict = {}
>>     for p in run_list:
>>       prefixes = p[0]
>> @@ -166,7 +174,7 @@ def main():
>>             continue
>> 
>>         # Print out the various check lines here.
>> -        asm.add_asm_checks(output_lines, ';', run_list, func_dict, func_name)
>> +        asm.add_asm_checks(output_lines, check_indent + ';', run_list, func_dict, func_name)
>>         is_in_function_start = False
>> 
>>       if is_in_function:
>> @@ -180,7 +188,7 @@ def main():
>>         continue
>> 
>>       # Discard any previous script advertising.
>> -      if input_line.startswith(ADVERT):
>> +      if input_line.startswith(comment_sym + ADVERT):
>>         continue
>> 
>>       # If it's outside a function, it just gets copied to the output.
>> 
>> 
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits



More information about the llvm-commits mailing list