diff --git a/llvm/utils/UpdateTestChecks/common.py b/llvm/utils/UpdateTestChecks/common.py --- a/llvm/utils/UpdateTestChecks/common.py +++ b/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) diff --git a/llvm/utils/update_cc_test_checks.py b/llvm/utils/update_cc_test_checks.py --- a/llvm/utils/update_cc_test_checks.py +++ b/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,23 @@ # 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 + 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,