OLD | NEW |
---|---|
1 #!/usr/bin/env python2 | 1 #!/usr/bin/env python2 |
2 | 2 |
3 import argparse | 3 import argparse |
4 import itertools | 4 import itertools |
5 import re | 5 import re |
6 | 6 |
7 if __name__ == '__main__': | 7 if __name__ == '__main__': |
8 """Compares a LLVM file with a subzero file for differences. | 8 """Compares a LLVM file with a subzero file for differences. |
9 | 9 |
10 Before comparing, the LLVM file is massaged to remove comments, | 10 Before comparing, the LLVM file is massaged to remove comments, |
(...skipping 24 matching lines...) Expand all Loading... | |
35 help='Subzero bitcode file [default stdin]') | 35 help='Subzero bitcode file [default stdin]') |
36 args = argparser.parse_args() | 36 args = argparser.parse_args() |
37 bitcode = args.llfile[0].readlines() | 37 bitcode = args.llfile[0].readlines() |
38 sz_out = [ line.rstrip() for line in args.szfile.readlines()] | 38 sz_out = [ line.rstrip() for line in args.szfile.readlines()] |
39 | 39 |
40 # Filter certain lines and patterns from the input, and collect | 40 # Filter certain lines and patterns from the input, and collect |
41 # the remainder into llc_out. | 41 # the remainder into llc_out. |
42 llc_out = [] | 42 llc_out = [] |
43 tail_call = re.compile(' tail call '); | 43 tail_call = re.compile(' tail call '); |
44 trailing_comment = re.compile(';.*') | 44 trailing_comment = re.compile(';.*') |
45 ignore_pattern = re.compile('^ *$|^declare|^@') | 45 ignore_pattern = re.compile('^ *$|^declare|^@.*\]$') |
Jim Stichnoth
2014/06/27 00:24:14
This makes szdiff not ignore global initializers.
| |
46 prev_line = None | 46 prev_line = None |
47 for line in bitcode: | 47 for line in bitcode: |
48 if prev_line: | 48 if prev_line: |
49 line = prev_line + line | 49 line = prev_line + line |
50 prev_line = None | 50 prev_line = None |
51 # Convert tail call into regular (non-tail) call. | 51 # Convert tail call into regular (non-tail) call. |
52 line = tail_call.sub(' call ', line) | 52 line = tail_call.sub(' call ', line) |
53 # Remove trailing comments and spaces. | 53 # Remove trailing comments and spaces. |
54 line = trailing_comment.sub('', line).rstrip() | 54 line = trailing_comment.sub('', line).rstrip() |
55 # Ignore blanks lines, forward declarations, and variable definitions. | 55 # Ignore blanks lines, forward declarations, and variable definitions. |
(...skipping 28 matching lines...) Expand all Loading... | |
84 lines_diff += 1 | 84 lines_diff += 1 |
85 continue | 85 continue |
86 if sz_line: print 'SZ (%d)> %s' % (lines_total, sz_line) | 86 if sz_line: print 'SZ (%d)> %s' % (lines_total, sz_line) |
87 if llc_line: print 'LL (%d)> %s' % (lines_total, llc_line) | 87 if llc_line: print 'LL (%d)> %s' % (lines_total, llc_line) |
88 return_code = 1 | 88 return_code = 1 |
89 | 89 |
90 if return_code == 0: | 90 if return_code == 0: |
91 message = 'Success (ignored %d diffs out of %d lines)' | 91 message = 'Success (ignored %d diffs out of %d lines)' |
92 print message % (lines_diff, lines_total) | 92 print message % (lines_diff, lines_total) |
93 exit(return_code) | 93 exit(return_code) |
OLD | NEW |