[PATCH] D97107: Replace func name with regex in update_cc_test_checks
Giorgis Georgakoudis via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 21 09:00:21 PST 2021
ggeorgakoudis updated this revision to Diff 325312.
ggeorgakoudis edited the summary of this revision.
ggeorgakoudis added a comment.
Fix to check regex input exists
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D97107/new/
https://reviews.llvm.org/D97107
Files:
llvm/utils/UpdateTestChecks/common.py
llvm/utils/update_cc_test_checks.py
Index: llvm/utils/update_cc_test_checks.py
===================================================================
--- llvm/utils/update_cc_test_checks.py
+++ llvm/utils/update_cc_test_checks.py
@@ -147,6 +147,8 @@
help='Keep function signature information around for the check line')
parser.add_argument('--check-attributes', action='store_true',
help='Check "Function Attributes" for functions')
+ parser.add_argument('--replace-function-regex', nargs='+',
+ help='List of regular expressions to replace matching function names')
parser.add_argument('tests', nargs='+')
args = common.parse_commandline_args(parser)
infer_dependent_args(args)
@@ -291,11 +293,24 @@
# Now generate all the checks.
def check_generator(my_output_lines, prefixes, func):
if '-emit-llvm' in clang_args:
+ func_repl = None
+ # Replace function name if matching a regex.
+ if initial_args.replace_function_regex:
+ for regex in initial_args.replace_function_regex:
+ match = re.match(regex, func)
+ if match:
+ func_repl = regex
+ for g in match.groups():
+ func_repl = re.sub('\(.*\)', g, func_repl)
+ func_repl = '{{' + func_repl + '}}'
+ # Break after the first matching regex.
+ break
+
common.add_ir_checks(my_output_lines, '//',
prefixes,
func_dict, func, False,
ti.args.function_signature,
- global_vars_seen_dict)
+ global_vars_seen_dict, func_repl)
else:
asm.add_asm_checks(my_output_lines, '//',
prefixes,
Index: llvm/utils/UpdateTestChecks/common.py
===================================================================
--- llvm/utils/UpdateTestChecks/common.py
+++ llvm/utils/UpdateTestChecks/common.py
@@ -577,7 +577,13 @@
break
def add_ir_checks(output_lines, comment_marker, prefix_list, func_dict,
- func_name, preserve_names, function_sig, global_vars_seen_dict):
+ func_name, preserve_names, function_sig, global_vars_seen_dict, func_name_repl=None):
+ # Replace function name.
+ if func_name_repl:
+ for prefix in func_dict:
+ if func_name in func_dict[prefix]:
+ func_dict[prefix][func_name_repl] = func_dict[prefix][func_name]
+ func_name = func_name_repl
# Label format is based on IR string.
function_def_regex = 'define {{[^@]+}}' if function_sig else ''
check_label_format = '{} %s-LABEL: {}@%s%s'.format(comment_marker, function_def_regex)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97107.325312.patch
Type: text/x-patch
Size: 2786 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210221/a9bc0035/attachment.bin>
More information about the llvm-commits
mailing list