[PATCH] D105319: update_mir_test_checks.py: add a flag --use-first-common-prefix
Amara Emerson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 1 15:59:29 PDT 2021
aemerson created this revision.
aemerson added a reviewer: arsenm.
aemerson added a project: LLVM.
aemerson requested review of this revision.
Herald added a subscriber: wdng.
update_mir_test_checks.py: add a flag `--use-first-common-prefix` to use the first common prefix found for generating checks, instead of ignoring them.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D105319
Files:
llvm/utils/update_mir_test_checks.py
Index: llvm/utils/update_mir_test_checks.py
===================================================================
--- llvm/utils/update_mir_test_checks.py
+++ llvm/utils/update_mir_test_checks.py
@@ -96,7 +96,7 @@
return None
-def build_run_list(test, run_lines, verbose=False):
+def build_run_list(test, run_lines, args):
run_list = []
all_prefixes = []
for l in run_lines:
@@ -142,8 +142,23 @@
# Remove any common prefixes. We'll just leave those entirely alone.
common_prefixes = set([prefix for prefix in all_prefixes
if all_prefixes.count(prefix) > 1])
- for run in run_list:
- run.prefixes = [p for p in run.prefixes if p not in common_prefixes]
+
+ # ...unless we're told to use the first one we see, ignoring the rest.
+ used_prefixes = set()
+ if args.use_first_common_prefix:
+ for run in run_list:
+ filtered_prefixes = []
+ for p in run.prefixes:
+ if p in common_prefixes:
+ if p not in used_prefixes:
+ filtered_prefixes.append(p)
+ used_prefixes.add(p)
+ else:
+ filtered_prefixes.append(p)
+ run.prefixes = filtered_prefixes
+ else:
+ for run in run_list:
+ run.prefixes = [p for p in run.prefixes if p not in common_prefixes]
return run_list, common_prefixes
@@ -297,7 +312,7 @@
triple_in_ir = find_triple_in_ir(input_lines, args.verbose)
run_lines = common.find_run_lines(test, input_lines)
- run_list, common_prefixes = build_run_list(test, run_lines, args.verbose)
+ run_list, common_prefixes = build_run_list(test, run_lines, args)
simple_functions = find_functions_with_one_bb(input_lines, args.verbose)
@@ -325,7 +340,7 @@
if args.remove_common_prefixes:
prefix_set.update(common_prefixes)
- elif common_prefixes:
+ elif common_prefixes and not args.use_first_common_prefix:
common.warn('Ignoring common prefixes: {}'.format(common_prefixes),
test_file=test)
@@ -418,6 +433,9 @@
parser.add_argument('--remove-common-prefixes', action='store_true',
help='Remove existing check lines whose prefixes are '
'shared between multiple commands')
+ parser.add_argument('--use-first-common-prefix', action='store_true',
+ help='If there are common prefixes shared between run lines,'
+ ' use the first one instead of ignoring them all')
parser.add_argument('tests', nargs='+')
args = common.parse_commandline_args(parser)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105319.356035.patch
Type: text/x-patch
Size: 2690 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210701/59d421ea/attachment.bin>
More information about the llvm-commits
mailing list