aboutsummaryrefslogtreecommitdiff
path: root/llvm/utils/UpdateTestChecks/common.py
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/utils/UpdateTestChecks/common.py')
-rw-r--r--llvm/utils/UpdateTestChecks/common.py23
1 files changed, 20 insertions, 3 deletions
diff --git a/llvm/utils/UpdateTestChecks/common.py b/llvm/utils/UpdateTestChecks/common.py
index ff48e3b..29d2240 100644
--- a/llvm/utils/UpdateTestChecks/common.py
+++ b/llvm/utils/UpdateTestChecks/common.py
@@ -36,9 +36,12 @@ def parse_commandline_args(parser):
help='List of regular expressions to replace matching value names')
parser.add_argument('--prefix-filecheck-ir-name', default='',
help='Add a prefix to FileCheck IR value names to avoid conflicts with scripted names')
+ parser.add_argument('--global-value-regex', nargs='+', default=[],
+ help='List of regular expressions that a global value declaration must match to generate a check (has no effect if checking globals is not enabled)')
args = parser.parse_args()
- global _verbose
+ global _verbose, _global_value_regex
_verbose = args.verbose
+ _global_value_regex = args.global_value_regex
return args
@@ -796,13 +799,27 @@ def add_global_checks(glob_val_dict, comment_marker, prefix_list, output_lines,
if not glob_val_dict[checkprefix][nameless_value.check_prefix]:
continue
- output_lines.append(comment_marker + SEPARATOR)
-
+ check_lines = []
global_vars_seen_before = [key for key in global_vars_seen.keys()]
for line in glob_val_dict[checkprefix][nameless_value.check_prefix]:
+ if _global_value_regex:
+ matched = False
+ for regex in _global_value_regex:
+ if re.match('^@' + regex + ' = ', line):
+ matched = True
+ break
+ if not matched:
+ continue
tmp = generalize_check_lines([line], is_analyze, set(), global_vars_seen)
check_line = '%s %s: %s' % (comment_marker, checkprefix, tmp[0])
+ check_lines.append(check_line)
+ if not check_lines:
+ continue
+
+ output_lines.append(comment_marker + SEPARATOR)
+ for check_line in check_lines:
output_lines.append(check_line)
+
printed_prefixes.add((checkprefix, nameless_value.check_prefix))
# Remembe new global variables we have not seen before