llvm.org GIT mirror llvm / b02fa51
Make utils/UpdateTestChecks/common.py Python 2/3 compatible and fix print statements. Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D42674 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@324104 91177308-0d34-0410-b5e6-96231b3b80d8 Fangrui Song 2 years ago
1 changed file(s) with 9 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
0 from __future__ import print_function
1 import re
12 import subprocess
3 import sys
24
35 RUN_LINE_RE = re.compile('^\s*;\s*RUN:\s*(.*)$')
46 CHECK_PREFIX_RE = re.compile('--?check-prefix(?:es)?=(\S+)')
3436 with open(ir) as ir_file:
3537 stdout = subprocess.check_output(exe + ' ' + cmd_args,
3638 shell=True, stdin=ir_file)
39 if sys.version_info[0] > 2:
40 stdout = stdout.decode()
3741 # Fix line endings to unix CR style.
38 stdout = stdout.replace('\r\n', '\n')
39 return stdout
42 return stdout.replace('\r\n', '\n')
4043
4144 # Build up a dictionary of all the function bodies.
4245 def build_function_body_dictionary(function_re, scrubber, scrubber_args, raw_tool_output, prefixes, func_dict, verbose):
4952 # We only use the last line of the function body for stress tests.
5053 scrubbed_body = '\n'.join(scrubbed_body.splitlines()[-1:])
5154 if verbose:
52 print >>sys.stderr, 'Processing function: ' + func
55 print('Processing function: ' + func, file=sys.stderr)
5356 for l in scrubbed_body.splitlines():
54 print >>sys.stderr, ' ' + l
57 print(' ' + l, file=sys.stderr)
5558 for prefix in prefixes:
5659 if func in func_dict[prefix] and func_dict[prefix][func] != scrubbed_body:
5760 if prefix == prefixes[-1]:
58 print >>sys.stderr, ('WARNING: Found conflicting asm under the '
59 'same prefix: %r!' % (prefix,))
61 print('WARNING: Found conflicting asm under the '
62 'same prefix: %r!' % (prefix,), file=sys.stderr)
6063 else:
6164 func_dict[prefix][func] = None
6265 continue