mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 02:33:06 +01:00
[UpdateCCTestChecks] Support --check-globals
This option is already supported by update_test_checks.py, but it can also be useful in update_cc_test_checks.py. For example, I'd like to use it in OpenMP offload codegen tests to check global variables like `.offload_maptypes*`. Reviewed By: jdoerfert, arichardson, ggeorgakoudis Differential Revision: https://reviews.llvm.org/D104714
This commit is contained in:
parent
b215117634
commit
6ae82bea96
@ -780,6 +780,8 @@ def add_global_checks(glob_val_dict, comment_marker, prefix_list, output_lines,
|
|||||||
for p in prefix_list:
|
for p in prefix_list:
|
||||||
global_vars_seen = {}
|
global_vars_seen = {}
|
||||||
checkprefixes = p[0]
|
checkprefixes = p[0]
|
||||||
|
if checkprefixes is None:
|
||||||
|
continue
|
||||||
for checkprefix in checkprefixes:
|
for checkprefix in checkprefixes:
|
||||||
if checkprefix in global_vars_seen_dict:
|
if checkprefix in global_vars_seen_dict:
|
||||||
global_vars_seen.update(global_vars_seen_dict[checkprefix])
|
global_vars_seen.update(global_vars_seen_dict[checkprefix])
|
||||||
|
@ -147,6 +147,8 @@ def config():
|
|||||||
help='Keep function signature information around for the check line')
|
help='Keep function signature information around for the check line')
|
||||||
parser.add_argument('--check-attributes', action='store_true',
|
parser.add_argument('--check-attributes', action='store_true',
|
||||||
help='Check "Function Attributes" for functions')
|
help='Check "Function Attributes" for functions')
|
||||||
|
parser.add_argument('--check-globals', action='store_true',
|
||||||
|
help='Check global entries (global variables, metadata, attribute sets, ...) for functions')
|
||||||
parser.add_argument('tests', nargs='+')
|
parser.add_argument('tests', nargs='+')
|
||||||
args = common.parse_commandline_args(parser)
|
args = common.parse_commandline_args(parser)
|
||||||
infer_dependent_args(args)
|
infer_dependent_args(args)
|
||||||
@ -301,6 +303,7 @@ def main():
|
|||||||
global_vars_seen_dict = {}
|
global_vars_seen_dict = {}
|
||||||
prefix_set = set([prefix for p in filecheck_run_list for prefix in p[0]])
|
prefix_set = set([prefix for p in filecheck_run_list for prefix in p[0]])
|
||||||
output_lines = []
|
output_lines = []
|
||||||
|
has_checked_pre_function_globals = False
|
||||||
|
|
||||||
include_generated_funcs = common.find_arg_in_test(ti,
|
include_generated_funcs = common.find_arg_in_test(ti,
|
||||||
lambda args: ti.args.include_generated_funcs,
|
lambda args: ti.args.include_generated_funcs,
|
||||||
@ -333,6 +336,10 @@ def main():
|
|||||||
prefixes,
|
prefixes,
|
||||||
func_dict, func)
|
func_dict, func)
|
||||||
|
|
||||||
|
if ti.args.check_globals:
|
||||||
|
common.add_global_checks(builder.global_var_dict(), '//', run_list,
|
||||||
|
output_lines, global_vars_seen_dict, True,
|
||||||
|
True)
|
||||||
common.add_checks_at_end(output_lines, filecheck_run_list, builder.func_order(),
|
common.add_checks_at_end(output_lines, filecheck_run_list, builder.func_order(),
|
||||||
'//', lambda my_output_lines, prefixes, func:
|
'//', lambda my_output_lines, prefixes, func:
|
||||||
check_generator(my_output_lines,
|
check_generator(my_output_lines,
|
||||||
@ -347,6 +354,9 @@ def main():
|
|||||||
m = common.CHECK_RE.match(line)
|
m = common.CHECK_RE.match(line)
|
||||||
if m and m.group(1) in prefix_set:
|
if m and m.group(1) in prefix_set:
|
||||||
continue # Don't append the existing CHECK lines
|
continue # Don't append the existing CHECK lines
|
||||||
|
# Skip special separator comments added by commmon.add_global_checks.
|
||||||
|
if line.strip() == '//' + common.SEPARATOR:
|
||||||
|
continue
|
||||||
if idx in line2spell_and_mangled_list:
|
if idx in line2spell_and_mangled_list:
|
||||||
added = set()
|
added = set()
|
||||||
for spell, mangled in line2spell_and_mangled_list[idx]:
|
for spell, mangled in line2spell_and_mangled_list[idx]:
|
||||||
@ -364,6 +374,11 @@ def main():
|
|||||||
# line as part of common.add_ir_checks()
|
# line as part of common.add_ir_checks()
|
||||||
output_lines.pop()
|
output_lines.pop()
|
||||||
last_line = output_lines[-1].strip()
|
last_line = output_lines[-1].strip()
|
||||||
|
if ti.args.check_globals and not has_checked_pre_function_globals:
|
||||||
|
common.add_global_checks(builder.global_var_dict(), '//',
|
||||||
|
run_list, output_lines,
|
||||||
|
global_vars_seen_dict, True, True)
|
||||||
|
has_checked_pre_function_globals = True
|
||||||
if added:
|
if added:
|
||||||
output_lines.append('//')
|
output_lines.append('//')
|
||||||
added.add(mangled)
|
added.add(mangled)
|
||||||
@ -375,6 +390,9 @@ def main():
|
|||||||
if include_line:
|
if include_line:
|
||||||
output_lines.append(line.rstrip('\n'))
|
output_lines.append(line.rstrip('\n'))
|
||||||
|
|
||||||
|
if ti.args.check_globals:
|
||||||
|
common.add_global_checks(builder.global_var_dict(), '//', run_list,
|
||||||
|
output_lines, global_vars_seen_dict, True, False)
|
||||||
common.debug('Writing %d lines to %s...' % (len(output_lines), ti.path))
|
common.debug('Writing %d lines to %s...' % (len(output_lines), ti.path))
|
||||||
with open(ti.path, 'wb') as f:
|
with open(ti.path, 'wb') as f:
|
||||||
f.writelines(['{}\n'.format(l).encode('utf-8') for l in output_lines])
|
f.writelines(['{}\n'.format(l).encode('utf-8') for l in output_lines])
|
||||||
|
Loading…
Reference in New Issue
Block a user