summaryrefslogtreecommitdiffstats
path: root/llvm/utils/UpdateTestChecks/common.py
diff options
context:
space:
mode:
authorSimon Pilgrim <llvm-dev@redking.me.uk>2018-06-01 13:37:01 +0000
committerSimon Pilgrim <llvm-dev@redking.me.uk>2018-06-01 13:37:01 +0000
commitee7694442d6ca7ed47bae8ffa3a766cbca68885b (patch)
tree09ab6c7ec020e4f14441d15b57f2e4431dc1c676 /llvm/utils/UpdateTestChecks/common.py
parent8467411dada9e05130e5d8e5244d07749f4fa5e6 (diff)
downloadbcm5719-llvm-ee7694442d6ca7ed47bae8ffa3a766cbca68885b.tar.gz
bcm5719-llvm-ee7694442d6ca7ed47bae8ffa3a766cbca68885b.zip
[Utils][X86] Help update_llc_test_checks.py to recognise retl/retq to reduce CHECK duplication (PR35003)
This patch replaces the --x86_extra_scrub command line argument to automatically support a second level of regex-scrubbing if it improves the matching of nearly-identical code patterns. The argument '--extra_scrub' is there now to force extra matching if required. This is mostly useful to help us share 32-bit/64-bit x86 vector tests which only differs by retl/retq instructions, but any scrubber can now technically support this, meaning test checks don't have to be needlessly obfuscated. I've updated some of the existing checks that had been manually run with --x86_extra_scrub, to demonstrate the extra "ret{{[l|q]}}" scrub now only happens when useful, and re-run the sse42-intrinsics file to show extra matches - most sse/avx intrinsics files should be able to now share 32/64 checks. Tested with the opt/analysis scripts as well which share common code - AFAICT the other update scripts use their own versions. Differential Revision: https://reviews.llvm.org/D47485 llvm-svn: 333749
Diffstat (limited to 'llvm/utils/UpdateTestChecks/common.py')
-rw-r--r--llvm/utils/UpdateTestChecks/common.py39
1 files changed, 30 insertions, 9 deletions
diff --git a/llvm/utils/UpdateTestChecks/common.py b/llvm/utils/UpdateTestChecks/common.py
index da076645320..daea395e31f 100644
--- a/llvm/utils/UpdateTestChecks/common.py
+++ b/llvm/utils/UpdateTestChecks/common.py
@@ -3,6 +3,7 @@ import re
import string
import subprocess
import sys
+import copy
if sys.version_info[0] > 2:
class string:
@@ -80,13 +81,29 @@ def scrub_body(body):
body = SCRUB_TRAILING_WHITESPACE_RE.sub(r'', body)
return body
+def do_scrub(body, scrubber, scrubber_args, extra):
+ if scrubber_args:
+ local_args = copy.deepcopy(scrubber_args)
+ local_args[0].extra_scrub = extra
+ return scrubber(body, *local_args)
+ return scrubber(body, *scrubber_args)
+
# Build up a dictionary of all the function bodies.
+class function_body(object):
+ def __init__(self, string, extra):
+ self.scrub = string
+ self.extrascrub = extra
+ def __str__(self):
+ return self.scrub
+
def build_function_body_dictionary(function_re, scrubber, scrubber_args, raw_tool_output, prefixes, func_dict, verbose):
for m in function_re.finditer(raw_tool_output):
if not m:
continue
func = m.group('func')
- scrubbed_body = scrubber(m.group('body'), *scrubber_args)
+ body = m.group('body')
+ scrubbed_body = do_scrub(body, scrubber, scrubber_args, extra = False)
+ scrubbed_extra = do_scrub(body, scrubber, scrubber_args, extra = True)
if m.groupdict().has_key('analysis'):
analysis = m.group('analysis')
if analysis.lower() != 'cost model analysis':
@@ -99,15 +116,19 @@ def build_function_body_dictionary(function_re, scrubber, scrubber_args, raw_too
for l in scrubbed_body.splitlines():
print(' ' + l, file=sys.stderr)
for prefix in prefixes:
- if func in func_dict[prefix] and func_dict[prefix][func] != scrubbed_body:
- if prefix == prefixes[-1]:
- print('WARNING: Found conflicting asm under the '
- 'same prefix: %r!' % (prefix,), file=sys.stderr)
- else:
- func_dict[prefix][func] = None
+ if func in func_dict[prefix] and str(func_dict[prefix][func]) != scrubbed_body:
+ if func_dict[prefix][func] and func_dict[prefix][func].extrascrub == scrubbed_extra:
+ func_dict[prefix][func].scrub = scrubbed_extra
continue
+ else:
+ if prefix == prefixes[-1]:
+ print('WARNING: Found conflicting asm under the '
+ 'same prefix: %r!' % (prefix,), file=sys.stderr)
+ else:
+ func_dict[prefix][func] = None
+ continue
- func_dict[prefix][func] = scrubbed_body
+ func_dict[prefix][func] = function_body(scrubbed_body, scrubbed_extra)
##### Generator of LLVM IR CHECK lines
@@ -188,7 +209,7 @@ def add_checks(output_lines, comment_marker, prefix_list, func_dict, func_name,
printed_prefixes.append(checkprefix)
output_lines.append(check_label_format % (checkprefix, func_name))
- func_body = func_dict[checkprefix][func_name].splitlines()
+ func_body = str(func_dict[checkprefix][func_name]).splitlines()
# For ASM output, just emit the check lines.
if is_asm == True:
OpenPOWER on IntegriCloud