[PATCH] D78478: [UpdateTestChecks] Add UTC_ARGS support for update_{llc,cc}_test_checks.py

2020-07-08 Thread Alexander Richardson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa80afc032859: [UpdateTestChecks] Add UTC_ARGS support for 
update_{llc,cc}_test_checks.py (authored by arichardson).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78478/new/

https://reviews.llvm.org/D78478

Files:
  clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.funcsig.expected
  clang/test/utils/update_cc_test_checks/Inputs/on_the_fly_arg_change.c
  clang/test/utils/update_cc_test_checks/Inputs/on_the_fly_arg_change.c.expected
  clang/test/utils/update_cc_test_checks/mangled_names.test
  clang/test/utils/update_cc_test_checks/on_the_fly_arg_change.test
  
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/basic.ll.expected
  
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/on_the_fly_arg_change.ll
  
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/on_the_fly_arg_change.ll.expected
  llvm/test/tools/UpdateTestChecks/update_llc_test_checks/basic.test
  
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/on_the_fly_arg_change.test
  llvm/utils/update_cc_test_checks.py
  llvm/utils/update_llc_test_checks.py

Index: llvm/utils/update_llc_test_checks.py
===
--- llvm/utils/update_llc_test_checks.py
+++ llvm/utils/update_llc_test_checks.py
@@ -10,19 +10,13 @@
 from __future__ import print_function
 
 import argparse
-import glob
-import os # Used to advertise this file's name ("autogenerated_note").
-import string
-import subprocess
-import sys
-import re
+import os  # Used to advertise this file's name ("autogenerated_note").
 
 from UpdateTestChecks import asm, common
 
-ADVERT = ' NOTE: Assertions have been autogenerated by '
 # llc is the only llc-like in the LLVM tree but downstream forks can add
 # additional ones here if they have them.
-LLC_LIKE_TOOLS = ('llc',) 
+LLC_LIKE_TOOLS = ('llc',)
 
 def main():
   parser = argparse.ArgumentParser(description=__doc__)
@@ -42,35 +36,21 @@
   '--no_x86_scrub_mem_shuffle', action='store_true', default=False,
   help='Reduce scrubbing shuffles with memory operands')
   parser.add_argument('tests', nargs='+')
-  args = common.parse_commandline_args(parser)
+  initial_args = common.parse_commandline_args(parser)
 
   script_name = os.path.basename(__file__)
 
-  test_paths = [test for pattern in args.tests for test in glob.glob(pattern)]
-  for test in test_paths:
-with open(test) as f:
-  input_lines = [l.rstrip() for l in f]
-
-first_line = input_lines[0] if input_lines else ""
-if 'autogenerated' in first_line and script_name not in first_line:
-  common.warn("Skipping test which wasn't autogenerated by " + script_name, test)
-  continue
-
-if args.update_only:
-  if not first_line or 'autogenerated' not in first_line:
-common.warn("Skipping test which isn't autogenerated: " + test)
-continue
-
+  for ti in common.itertests(initial_args.tests, parser,
+ script_name='utils/' + script_name):
 triple_in_ir = None
-for l in input_lines:
+for l in ti.input_lines:
   m = common.TRIPLE_IR_RE.match(l)
   if m:
 triple_in_ir = m.groups()[0]
 break
 
-run_lines = common.find_run_lines(test, input_lines)
 run_list = []
-for l in run_lines:
+for l in ti.run_lines:
   if '|' not in l:
 common.warn('Skipping unparseable RUN line: ' + l)
 continue
@@ -103,7 +83,7 @@
 
   llc_cmd_args = llc_cmd[len(llc_tool):].strip()
   llc_cmd_args = llc_cmd_args.replace('< %s', '').replace('%s', '').strip()
-  if test.endswith('.mir'):
+  if ti.path.endswith('.mir'):
 llc_cmd_args += ' -x mir'
   check_prefixes = [item for m in common.CHECK_PREFIX_RE.finditer(filecheck_cmd)
for item in m.group(1).split(',')]
@@ -114,13 +94,10 @@
   # now, we just ignore all but the last.
   run_list.append((check_prefixes, llc_cmd_args, triple_in_cmd, march_in_cmd))
 
-if test.endswith('.mir'):
-  comment_sym = '#'
+if ti.path.endswith('.mir'):
   check_indent = '  '
 else:
-  comment_sym = ';'
   check_indent = ''
-autogenerated_note = (comment_sym + ADVERT + 'utils/' + script_name)
 
 func_dict = {}
 for p in run_list:
@@ -131,13 +108,12 @@
   common.debug('Extracted LLC cmd:', llc_tool, llc_args)
   common.debug('Extracted FileCheck prefixes:', str(prefixes))
 
-  raw_tool_output = common.invoke_tool(args.llc_binary or llc_tool,
-   llc_args, test)
+  raw_tool_output = common.invoke_tool(ti.args.llc_binary or llc_tool, llc_args, ti.path)
   triple = triple_in_cmd or triple_in_ir
   if not triple:
 triple = asm.get_triple_from_march(march_in_cmd)
 
-  asm.build_function_body_dictionary_for_triple(args, 

[PATCH] D78478: [UpdateTestChecks] Add UTC_ARGS support for update_{llc,cc}_test_checks.py

2020-07-08 Thread Alexander Richardson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa80afc032859: [UpdateTestChecks] Add UTC_ARGS support for 
update_{llc,cc}_test_checks.py (authored by arichardson).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78478/new/

https://reviews.llvm.org/D78478

Files:
  clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.funcsig.expected
  clang/test/utils/update_cc_test_checks/Inputs/on_the_fly_arg_change.c
  clang/test/utils/update_cc_test_checks/Inputs/on_the_fly_arg_change.c.expected
  clang/test/utils/update_cc_test_checks/mangled_names.test
  clang/test/utils/update_cc_test_checks/on_the_fly_arg_change.test
  
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/basic.ll.expected
  
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/on_the_fly_arg_change.ll
  
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/on_the_fly_arg_change.ll.expected
  llvm/test/tools/UpdateTestChecks/update_llc_test_checks/basic.test
  
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/on_the_fly_arg_change.test
  llvm/utils/update_cc_test_checks.py
  llvm/utils/update_llc_test_checks.py

Index: llvm/utils/update_llc_test_checks.py
===
--- llvm/utils/update_llc_test_checks.py
+++ llvm/utils/update_llc_test_checks.py
@@ -10,19 +10,13 @@
 from __future__ import print_function
 
 import argparse
-import glob
-import os # Used to advertise this file's name ("autogenerated_note").
-import string
-import subprocess
-import sys
-import re
+import os  # Used to advertise this file's name ("autogenerated_note").
 
 from UpdateTestChecks import asm, common
 
-ADVERT = ' NOTE: Assertions have been autogenerated by '
 # llc is the only llc-like in the LLVM tree but downstream forks can add
 # additional ones here if they have them.
-LLC_LIKE_TOOLS = ('llc',) 
+LLC_LIKE_TOOLS = ('llc',)
 
 def main():
   parser = argparse.ArgumentParser(description=__doc__)
@@ -42,35 +36,21 @@
   '--no_x86_scrub_mem_shuffle', action='store_true', default=False,
   help='Reduce scrubbing shuffles with memory operands')
   parser.add_argument('tests', nargs='+')
-  args = common.parse_commandline_args(parser)
+  initial_args = common.parse_commandline_args(parser)
 
   script_name = os.path.basename(__file__)
 
-  test_paths = [test for pattern in args.tests for test in glob.glob(pattern)]
-  for test in test_paths:
-with open(test) as f:
-  input_lines = [l.rstrip() for l in f]
-
-first_line = input_lines[0] if input_lines else ""
-if 'autogenerated' in first_line and script_name not in first_line:
-  common.warn("Skipping test which wasn't autogenerated by " + script_name, test)
-  continue
-
-if args.update_only:
-  if not first_line or 'autogenerated' not in first_line:
-common.warn("Skipping test which isn't autogenerated: " + test)
-continue
-
+  for ti in common.itertests(initial_args.tests, parser,
+ script_name='utils/' + script_name):
 triple_in_ir = None
-for l in input_lines:
+for l in ti.input_lines:
   m = common.TRIPLE_IR_RE.match(l)
   if m:
 triple_in_ir = m.groups()[0]
 break
 
-run_lines = common.find_run_lines(test, input_lines)
 run_list = []
-for l in run_lines:
+for l in ti.run_lines:
   if '|' not in l:
 common.warn('Skipping unparseable RUN line: ' + l)
 continue
@@ -103,7 +83,7 @@
 
   llc_cmd_args = llc_cmd[len(llc_tool):].strip()
   llc_cmd_args = llc_cmd_args.replace('< %s', '').replace('%s', '').strip()
-  if test.endswith('.mir'):
+  if ti.path.endswith('.mir'):
 llc_cmd_args += ' -x mir'
   check_prefixes = [item for m in common.CHECK_PREFIX_RE.finditer(filecheck_cmd)
for item in m.group(1).split(',')]
@@ -114,13 +94,10 @@
   # now, we just ignore all but the last.
   run_list.append((check_prefixes, llc_cmd_args, triple_in_cmd, march_in_cmd))
 
-if test.endswith('.mir'):
-  comment_sym = '#'
+if ti.path.endswith('.mir'):
   check_indent = '  '
 else:
-  comment_sym = ';'
   check_indent = ''
-autogenerated_note = (comment_sym + ADVERT + 'utils/' + script_name)
 
 func_dict = {}
 for p in run_list:
@@ -131,13 +108,12 @@
   common.debug('Extracted LLC cmd:', llc_tool, llc_args)
   common.debug('Extracted FileCheck prefixes:', str(prefixes))
 
-  raw_tool_output = common.invoke_tool(args.llc_binary or llc_tool,
-   llc_args, test)
+  raw_tool_output = common.invoke_tool(ti.args.llc_binary or llc_tool, llc_args, ti.path)
   triple = triple_in_cmd or triple_in_ir
   if not triple:
 triple = asm.get_triple_from_march(march_in_cmd)
 
-  asm.build_function_body_dictionary_for_triple(args, 

[PATCH] D78478: [UpdateTestChecks] Add UTC_ARGS support for update_{llc,cc}_test_checks.py

2020-07-07 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.

LGTM.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78478/new/

https://reviews.llvm.org/D78478



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D78478: [UpdateTestChecks] Add UTC_ARGS support for update_{llc,cc}_test_checks.py

2020-07-07 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson added a comment.

@MaskRay are you okay with me committing this change and delaying the global 
search-replace?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78478/new/

https://reviews.llvm.org/D78478



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D78478: [UpdateTestChecks] Add UTC_ARGS support for update_{llc,cc}_test_checks.py

2020-07-02 Thread Sanjay Patel via Phabricator via cfe-commits
spatel added a comment.

In D78478#2128631 , @xbolva00 wrote:

> >> UTC_ARGS (I can't help associating it with Coordinated Universal Time).
>
> Me too. Any suggestions for new name? TCU_ARGS?


I also reflexively think of universal time when reading "UTC". I think we 
always print this with the script name advertisement line, so "SCRIPT_ARGS" 
seems non-ambiguous.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78478/new/

https://reviews.llvm.org/D78478



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D78478: [UpdateTestChecks] Add UTC_ARGS support for update_{llc,cc}_test_checks.py

2020-07-02 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D78478#2128926 , @arichardson wrote:

> In D78478#2128604 , @MaskRay wrote:
>
> > The idea look good to me, but I want some opinions on the name `UTC_ARGS` 
> > (I can't help associating it with Coordinated Universal Time). Adding some 
> > folks who may have opinions: @greened @lebedev.ri  @RKSimon @spatel  
> > @xbolva00
>
>
> I agree that UTC_ARGS could be a bit confusing. However, there are currently 
> 145 UTC_ARGS uses in tests/Transforms and I'd rather not update them as part 
> of this change.
>
> I feel that changing the name should be a separate change that can be 
> committed after this patch.


Yes, please. The name is my fault, but naming things is hard :(

@MaskRay If you have an alternative name, I propose a `sed -e/UTC_ARGS/.../` 
patch, maybe with a check in here warning if UTC_ARGS is used.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78478/new/

https://reviews.llvm.org/D78478



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D78478: [UpdateTestChecks] Add UTC_ARGS support for update_{llc,cc}_test_checks.py

2020-07-02 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson added a comment.

In D78478#2128604 , @MaskRay wrote:

> The idea look good to me, but I want some opinions on the name `UTC_ARGS` (I 
> can't help associating it with Coordinated Universal Time). Adding some folks 
> who may have opinions: @greened @lebedev.ri  @RKSimon @spatel  @xbolva00


I agree that UTC_ARGS could be a bit confusing. However, there are currently 
145 UTC_ARGS uses in tests/Transforms and I'd rather not update them as part of 
this change.

I feel that changing the name should be a separate change that can be committed 
after this patch.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78478/new/

https://reviews.llvm.org/D78478



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D78478: [UpdateTestChecks] Add UTC_ARGS support for update_{llc,cc}_test_checks.py

2020-07-02 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

>> UTC_ARGS (I can't help associating it with Coordinated Universal Time).

Me too. Any suggestions for new name? TCU_ARGS?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78478/new/

https://reviews.llvm.org/D78478



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D78478: [UpdateTestChecks] Add UTC_ARGS support for update_{llc,cc}_test_checks.py

2020-07-02 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added subscribers: xbolva00, greened, spatel, lebedev.ri.
MaskRay added a comment.

The idea look good to me, but I want some opinions on the name `UTC_ARGS` (I 
can't help associating it with Coordinated Universal Time). Adding some folks 
who may have opinions: @greened @lebedev.ri  @RKSimon @spatel  @xbolva00


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78478/new/

https://reviews.llvm.org/D78478



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D78478: [UpdateTestChecks] Add UTC_ARGS support for update_{llc,cc}_test_checks.py

2020-07-02 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert added a comment.
This revision is now accepted and ready to land.

Nice cleanup again!

I think eventually we need to teach the common logic to recognize top-level 
entities, e.g., functions, and with these changes it will be accessible w/o 
duplication in all update scripts, YaY!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78478/new/

https://reviews.llvm.org/D78478



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D78478: [UpdateTestChecks] Add UTC_ARGS support for update_{llc,cc}_test_checks.py

2020-06-30 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson updated this revision to Diff 274427.
arichardson added a comment.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78478/new/

https://reviews.llvm.org/D78478

Files:
  clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.funcsig.expected
  clang/test/utils/update_cc_test_checks/Inputs/on_the_fly_arg_change.c
  clang/test/utils/update_cc_test_checks/Inputs/on_the_fly_arg_change.c.expected
  clang/test/utils/update_cc_test_checks/mangled_names.test
  clang/test/utils/update_cc_test_checks/on_the_fly_arg_change.test
  
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/basic.ll.expected
  
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/on_the_fly_arg_change.ll
  
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/on_the_fly_arg_change.ll.expected
  llvm/test/tools/UpdateTestChecks/update_llc_test_checks/basic.test
  
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/on_the_fly_arg_change.test
  llvm/utils/update_cc_test_checks.py
  llvm/utils/update_llc_test_checks.py

Index: llvm/utils/update_llc_test_checks.py
===
--- llvm/utils/update_llc_test_checks.py
+++ llvm/utils/update_llc_test_checks.py
@@ -10,19 +10,13 @@
 from __future__ import print_function
 
 import argparse
-import glob
-import os # Used to advertise this file's name ("autogenerated_note").
-import string
-import subprocess
-import sys
-import re
+import os  # Used to advertise this file's name ("autogenerated_note").
 
 from UpdateTestChecks import asm, common
 
-ADVERT = ' NOTE: Assertions have been autogenerated by '
 # llc is the only llc-like in the LLVM tree but downstream forks can add
 # additional ones here if they have them.
-LLC_LIKE_TOOLS = ('llc',) 
+LLC_LIKE_TOOLS = ('llc',)
 
 def main():
   parser = argparse.ArgumentParser(description=__doc__)
@@ -42,35 +36,21 @@
   '--no_x86_scrub_mem_shuffle', action='store_true', default=False,
   help='Reduce scrubbing shuffles with memory operands')
   parser.add_argument('tests', nargs='+')
-  args = common.parse_commandline_args(parser)
+  initial_args = common.parse_commandline_args(parser)
 
   script_name = os.path.basename(__file__)
 
-  test_paths = [test for pattern in args.tests for test in glob.glob(pattern)]
-  for test in test_paths:
-with open(test) as f:
-  input_lines = [l.rstrip() for l in f]
-
-first_line = input_lines[0] if input_lines else ""
-if 'autogenerated' in first_line and script_name not in first_line:
-  common.warn("Skipping test which wasn't autogenerated by " + script_name, test)
-  continue
-
-if args.update_only:
-  if not first_line or 'autogenerated' not in first_line:
-common.warn("Skipping test which isn't autogenerated: " + test)
-continue
-
+  for ti in common.itertests(initial_args.tests, parser,
+ script_name='utils/' + script_name):
 triple_in_ir = None
-for l in input_lines:
+for l in ti.input_lines:
   m = common.TRIPLE_IR_RE.match(l)
   if m:
 triple_in_ir = m.groups()[0]
 break
 
-run_lines = common.find_run_lines(test, input_lines)
 run_list = []
-for l in run_lines:
+for l in ti.run_lines:
   if '|' not in l:
 common.warn('Skipping unparseable RUN line: ' + l)
 continue
@@ -103,7 +83,7 @@
 
   llc_cmd_args = llc_cmd[len(llc_tool):].strip()
   llc_cmd_args = llc_cmd_args.replace('< %s', '').replace('%s', '').strip()
-  if test.endswith('.mir'):
+  if ti.path.endswith('.mir'):
 llc_cmd_args += ' -x mir'
   check_prefixes = [item for m in common.CHECK_PREFIX_RE.finditer(filecheck_cmd)
for item in m.group(1).split(',')]
@@ -114,13 +94,10 @@
   # now, we just ignore all but the last.
   run_list.append((check_prefixes, llc_cmd_args, triple_in_cmd, march_in_cmd))
 
-if test.endswith('.mir'):
-  comment_sym = '#'
+if ti.path.endswith('.mir'):
   check_indent = '  '
 else:
-  comment_sym = ';'
   check_indent = ''
-autogenerated_note = (comment_sym + ADVERT + 'utils/' + script_name)
 
 func_dict = {}
 for p in run_list:
@@ -131,13 +108,12 @@
   common.debug('Extracted LLC cmd:', llc_tool, llc_args)
   common.debug('Extracted FileCheck prefixes:', str(prefixes))
 
-  raw_tool_output = common.invoke_tool(args.llc_binary or llc_tool,
-   llc_args, test)
+  raw_tool_output = common.invoke_tool(ti.args.llc_binary or llc_tool, llc_args, ti.path)
   triple = triple_in_cmd or triple_in_ir
   if not triple:
 triple = asm.get_triple_from_march(march_in_cmd)
 
-  asm.build_function_body_dictionary_for_triple(args, raw_tool_output,
+  

[PATCH] D78478: [UpdateTestChecks] Add UTC_ARGS support for update_{llc,cc}_test_checks.py

2020-04-22 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson updated this revision to Diff 259210.
arichardson added a comment.

Split into multiple reviews


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78478/new/

https://reviews.llvm.org/D78478

Files:
  clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.funcsig.expected
  clang/test/utils/update_cc_test_checks/Inputs/on_the_fly_arg_change.c
  clang/test/utils/update_cc_test_checks/Inputs/on_the_fly_arg_change.c.expected
  clang/test/utils/update_cc_test_checks/mangled_names.test
  clang/test/utils/update_cc_test_checks/on_the_fly_arg_change.test
  
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/basic.ll.expected
  
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/on_the_fly_arg_change.ll
  
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/on_the_fly_arg_change.ll.expected
  llvm/test/tools/UpdateTestChecks/update_llc_test_checks/basic.test
  
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/on_the_fly_arg_change.test
  llvm/utils/update_cc_test_checks.py
  llvm/utils/update_llc_test_checks.py

Index: llvm/utils/update_llc_test_checks.py
===
--- llvm/utils/update_llc_test_checks.py
+++ llvm/utils/update_llc_test_checks.py
@@ -10,17 +10,10 @@
 from __future__ import print_function
 
 import argparse
-import glob
-import os # Used to advertise this file's name ("autogenerated_note").
-import string
-import subprocess
-import sys
-import re
+import os  # Used to advertise this file's name ("autogenerated_note").
 
 from UpdateTestChecks import asm, common
 
-ADVERT = ' NOTE: Assertions have been autogenerated by '
-
 
 def main():
   parser = argparse.ArgumentParser(description=__doc__)
@@ -40,35 +33,21 @@
   '--no_x86_scrub_mem_shuffle', action='store_true', default=False,
   help='Reduce scrubbing shuffles with memory operands')
   parser.add_argument('tests', nargs='+')
-  args = common.parse_commandline_args(parser)
+  initial_args = common.parse_commandline_args(parser)
 
   script_name = os.path.basename(__file__)
 
-  test_paths = [test for pattern in args.tests for test in glob.glob(pattern)]
-  for test in test_paths:
-with open(test) as f:
-  input_lines = [l.rstrip() for l in f]
-
-first_line = input_lines[0] if input_lines else ""
-if 'autogenerated' in first_line and script_name not in first_line:
-  common.warn("Skipping test which wasn't autogenerated by " + script_name, test)
-  continue
-
-if args.update_only:
-  if not first_line or 'autogenerated' not in first_line:
-common.warn("Skipping test which isn't autogenerated: " + test)
-continue
-
+  for ti in common.itertests(initial_args.tests, parser,
+ script_name='utils/' + script_name):
 triple_in_ir = None
-for l in input_lines:
+for l in ti.input_lines:
   m = common.TRIPLE_IR_RE.match(l)
   if m:
 triple_in_ir = m.groups()[0]
 break
 
-run_lines = common.find_run_lines(test, input_lines)
 run_list = []
-for l in run_lines:
+for l in ti.run_lines:
   if '|' not in l:
 common.warn('Skipping unparseable RUN line: ' + l)
 continue
@@ -101,7 +80,7 @@
 
   llc_cmd_args = llc_cmd[len(llc_tool):].strip()
   llc_cmd_args = llc_cmd_args.replace('< %s', '').replace('%s', '').strip()
-  if test.endswith('.mir'):
+  if ti.path.endswith('.mir'):
 llc_cmd_args += ' -x mir'
   check_prefixes = [item for m in common.CHECK_PREFIX_RE.finditer(filecheck_cmd)
for item in m.group(1).split(',')]
@@ -112,13 +91,10 @@
   # now, we just ignore all but the last.
   run_list.append((check_prefixes, llc_cmd_args, triple_in_cmd, march_in_cmd))
 
-if test.endswith('.mir'):
-  comment_sym = '#'
+if ti.path.endswith('.mir'):
   check_indent = '  '
 else:
-  comment_sym = ';'
   check_indent = ''
-autogenerated_note = (comment_sym + ADVERT + 'utils/' + script_name)
 
 func_dict = {}
 for p in run_list:
@@ -129,12 +105,12 @@
   common.debug('Extracted LLC cmd:', llc_tool, llc_args)
   common.debug('Extracted FileCheck prefixes:', str(prefixes))
 
-  raw_tool_output = common.invoke_tool(args.llc_binary, llc_args, test)
+  raw_tool_output = common.invoke_tool(ti.args.llc_binary, llc_args, ti.path)
   triple = triple_in_cmd or triple_in_ir
   if not triple:
 triple = asm.get_triple_from_march(march_in_cmd)
 
-  asm.build_function_body_dictionary_for_triple(args, raw_tool_output,
+  asm.build_function_body_dictionary_for_triple(ti.args, raw_tool_output,
   triple, prefixes, func_dict)
 
 is_in_function = False
@@ -143,9 +119,9 @@
 prefix_set = set([prefix for p in run_list for prefix in p[0]])
 common.debug('Rewriting FileCheck prefixes:', str(prefix_set))
 output_lines 

[PATCH] D78478: [UpdateTestChecks] Add UTC_ARGS support for update_{llc,cc}_test_checks.py

2020-04-22 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson added a comment.

In D78478#1994923 , @jdoerfert wrote:

> I feel there is a lot of good stuff here but it seems to mix two things. A 
> rewrite of the script infrastructure and the UTC_ARGS stuff. If so, do you 
> think we could split them? I feel there are also minor NFC changes that could 
> go in on their own without review, I marked on of them below.
>
> (Partially related: Does this handle the mismatch between `enabled` 
> configuration status and the flag names `enable/disable` or will it still add 
> `--enabled` to the UTC_ARGS?)


It will now read the command line flag that was specified when calling 
parser.add_argument() and should do the right thing.

I'll split out the unrelated changes to separate reviews.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78478/new/

https://reviews.llvm.org/D78478



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D78478: [UpdateTestChecks] Add UTC_ARGS support for update_{llc,cc}_test_checks.py

2020-04-21 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

I feel there is a lot of good stuff here but it seems to mix two things. A 
rewrite of the script infrastructure and the UTC_ARGS stuff. If so, do you 
think we could split them? I feel there are also minor NFC changes that could 
go in on their own without review, I marked on of them below.

(Partially related: Does this handle the mismatch between `enabled` 
configuration status and the flag names `enable/disable` or will it still add 
`--enabled` to the UTC_ARGS?)




Comment at: llvm/utils/update_cc_test_checks.py:109
   help='"clang" executable, defaults to $llvm_bin/clang')
-  parser.add_argument('--clang-args',
+  parser.add_argument('--clang-args', default=[], type=str_to_commandline,
   help='Space-separated extra args to clang, e.g. 
--clang-args=-v')

I guess these 7 lines can be committed on their own as NFC cleanup.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78478/new/

https://reviews.llvm.org/D78478



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D78478: [UpdateTestChecks] Add UTC_ARGS support for update_{llc,cc}_test_checks.py

2020-04-20 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson created this revision.
arichardson added reviewers: jdoerfert, MaskRay.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

https://reviews.llvm.org/D69701 added support for on-the-fly argument
changes for update scripts. I recently wanted to keep some manual check
lines in a test generated by update_cc_test_checks.py in our CHERI fork, so
this commit adds support for UTC_ARGS in update_cc_test_checks.py. And since
I was refactoring the code to be in common.py, I also added it for
update_llc_test_checks.py.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78478

Files:
  clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.funcsig.expected
  clang/test/utils/update_cc_test_checks/Inputs/on_the_fly_arg_change.c
  clang/test/utils/update_cc_test_checks/Inputs/on_the_fly_arg_change.c.expected
  clang/test/utils/update_cc_test_checks/mangled_names.test
  clang/test/utils/update_cc_test_checks/on_the_fly_arg_change.test
  
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/basic.ll.expected
  
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/on_the_fly_arg_change.ll
  
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/on_the_fly_arg_change.ll.expected
  llvm/test/tools/UpdateTestChecks/update_llc_test_checks/basic.test
  
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/on_the_fly_arg_change.test
  llvm/utils/UpdateTestChecks/common.py
  llvm/utils/update_cc_test_checks.py
  llvm/utils/update_llc_test_checks.py
  llvm/utils/update_test_checks.py

Index: llvm/utils/update_test_checks.py
===
--- llvm/utils/update_test_checks.py
+++ llvm/utils/update_test_checks.py
@@ -32,18 +32,12 @@
 from __future__ import print_function
 
 import argparse
-import glob
-import itertools
-import os # Used to advertise this file's name ("autogenerated_note").
-import string
-import subprocess
-import sys
-import tempfile
+import os  # Used to advertise this file's name ("autogenerated_note").
 import re
+import sys
 
 from UpdateTestChecks import common
 
-ADVERT = '; NOTE: Assertions have been autogenerated by '
 
 def main():
   from argparse import RawTextHelpFormatter
@@ -58,58 +52,26 @@
   help='Keep function signature information around for the check line')
   parser.add_argument('--scrub-attributes', action='store_true',
   help='Remove attribute annotations (#0) from the end of check line')
-  parser.add_argument('--enable', action='store_true', dest='enabled', default=True,
-  help='Activate CHECK line generation from this point forward')
-  parser.add_argument('--disable', action='store_false', dest='enabled',
-  help='Deactivate CHECK line generation from this point forward')
   parser.add_argument('tests', nargs='+')
-  args = common.parse_commandline_args(parser)
+  initial_args = common.parse_commandline_args(parser)
 
   script_name = os.path.basename(__file__)
-  autogenerated_note = (ADVERT + 'utils/' + script_name)
-
-  opt_basename = os.path.basename(args.opt_binary)
+  opt_basename = os.path.basename(initial_args.opt_binary)
   if not re.match(r'^opt(-\d+)?$', opt_basename):
 common.error('Unexpected opt name: ' + opt_basename)
 sys.exit(1)
   opt_basename = 'opt'
 
-  for test in args.tests:
-if not glob.glob(test):
-  common.warn("Test file pattern '%s' was not found. Ignoring it." % (test,))
-  continue
-
-  # On Windows we must expand the patterns ourselves.
-  test_paths = [test for pattern in args.tests for test in glob.glob(pattern)]
-  for test in test_paths:
-argv = sys.argv[:]
-args = parser.parse_args()
-with open(test) as f:
-  input_lines = [l.rstrip() for l in f]
-
-first_line = input_lines[0] if input_lines else ""
-if 'autogenerated' in first_line and script_name not in first_line:
-  common.warn("Skipping test which wasn't autogenerated by " + script_name, test)
-  continue
-if first_line and 'autogenerated' in first_line:
-  args, argv = common.check_for_command(first_line, parser, args, argv)
-test_autogenerated_note = autogenerated_note + common.get_autogennote_suffix(parser, args)
-
-if args.update_only:
-  if not first_line or 'autogenerated' not in first_line:
-common.warn("Skipping test which isn't autogenerated: " + test)
-continue
-
-run_lines = common.find_run_lines(test, input_lines)
-
+  for ti in common.itertests(initial_args.tests, parser,
+ script_name='utils/' + script_name):
 # If requested we scrub trailing attribute annotations, e.g., '#0', together with whitespaces
-if args.scrub_attributes:
+if ti.args.scrub_attributes:
   common.SCRUB_TRAILING_WHITESPACE_TEST_RE = common.SCRUB_TRAILING_WHITESPACE_AND_ATTRIBUTES_RE
 else:
   common.SCRUB_TRAILING_WHITESPACE_TEST_RE =