mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 03:02:36 +01:00
Fix some opt-viewer test issues and disable on Windows.
Differential Revision: https://reviews.llvm.org/D41784 llvm-svn: 321905
This commit is contained in:
parent
7e84865cb2
commit
5e632d7ff2
@ -1,2 +1,10 @@
|
|||||||
|
import sys
|
||||||
|
|
||||||
if 'have_opt_viewer_modules' not in config.available_features:
|
if 'have_opt_viewer_modules' not in config.available_features:
|
||||||
config.unsupported = True
|
config.unsupported = True
|
||||||
|
|
||||||
|
# Windows has different multiprocessing behavior than non-Windows, which causes
|
||||||
|
# all of the tests to fail presently under Windows. Disable this until those
|
||||||
|
# can be resolved.
|
||||||
|
if sys.platform == 'win32':
|
||||||
|
config.unsupported = True
|
||||||
|
@ -19,7 +19,6 @@ except ImportError:
|
|||||||
import optrecord
|
import optrecord
|
||||||
import argparse
|
import argparse
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from multiprocessing import cpu_count, Pool
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
parser = argparse.ArgumentParser(description=desc)
|
parser = argparse.ArgumentParser(description=desc)
|
||||||
@ -34,7 +33,7 @@ if __name__ == '__main__':
|
|||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--jobs',
|
'--jobs',
|
||||||
'-j',
|
'-j',
|
||||||
default=cpu_count(),
|
default=None,
|
||||||
type=int,
|
type=int,
|
||||||
help='Max job count (defaults to %(default)s, the current CPU count)')
|
help='Max job count (defaults to %(default)s, the current CPU count)')
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
|
@ -30,7 +30,7 @@ if __name__ == '__main__':
|
|||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--jobs',
|
'--jobs',
|
||||||
'-j',
|
'-j',
|
||||||
default=cpu_count(),
|
default=None,
|
||||||
type=int,
|
type=int,
|
||||||
help='Max job count (defaults to %(default)s, the current CPU count)')
|
help='Max job count (defaults to %(default)s, the current CPU count)')
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
|
@ -43,7 +43,7 @@ def suppress(remark):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
class SourceFileRenderer:
|
class SourceFileRenderer:
|
||||||
def __init__(self, source_dir, output_dir, filename):
|
def __init__(self, source_dir, output_dir, filename, no_highlight):
|
||||||
existing_filename = None
|
existing_filename = None
|
||||||
if os.path.exists(filename):
|
if os.path.exists(filename):
|
||||||
existing_filename = filename
|
existing_filename = filename
|
||||||
@ -52,6 +52,7 @@ class SourceFileRenderer:
|
|||||||
if os.path.exists(fn):
|
if os.path.exists(fn):
|
||||||
existing_filename = fn
|
existing_filename = fn
|
||||||
|
|
||||||
|
self.no_highlight = no_highlight
|
||||||
self.stream = codecs.open(os.path.join(output_dir, optrecord.html_file_name(filename)), 'w', encoding='utf-8')
|
self.stream = codecs.open(os.path.join(output_dir, optrecord.html_file_name(filename)), 'w', encoding='utf-8')
|
||||||
if existing_filename:
|
if existing_filename:
|
||||||
self.source_stream = open(existing_filename)
|
self.source_stream = open(existing_filename)
|
||||||
@ -69,7 +70,7 @@ class SourceFileRenderer:
|
|||||||
def render_source_lines(self, stream, line_remarks):
|
def render_source_lines(self, stream, line_remarks):
|
||||||
file_text = stream.read()
|
file_text = stream.read()
|
||||||
|
|
||||||
if args.no_highlight:
|
if self.no_highlight:
|
||||||
html_highlighted = file_text.decode('utf-8')
|
html_highlighted = file_text.decode('utf-8')
|
||||||
else:
|
else:
|
||||||
html_highlighted = highlight(
|
html_highlighted = highlight(
|
||||||
@ -157,9 +158,10 @@ class SourceFileRenderer:
|
|||||||
|
|
||||||
|
|
||||||
class IndexRenderer:
|
class IndexRenderer:
|
||||||
def __init__(self, output_dir, should_display_hotness):
|
def __init__(self, output_dir, should_display_hotness, max_hottest_remarks_on_index):
|
||||||
self.stream = codecs.open(os.path.join(output_dir, 'index.html'), 'w', encoding='utf-8')
|
self.stream = codecs.open(os.path.join(output_dir, 'index.html'), 'w', encoding='utf-8')
|
||||||
self.should_display_hotness = should_display_hotness
|
self.should_display_hotness = should_display_hotness
|
||||||
|
self.max_hottest_remarks_on_index = max_hottest_remarks_on_index
|
||||||
|
|
||||||
def render_entry(self, r, odd):
|
def render_entry(self, r, odd):
|
||||||
escaped_name = cgi.escape(r.DemangledFunctionName)
|
escaped_name = cgi.escape(r.DemangledFunctionName)
|
||||||
@ -189,8 +191,8 @@ class IndexRenderer:
|
|||||||
</tr>''', file=self.stream)
|
</tr>''', file=self.stream)
|
||||||
|
|
||||||
max_entries = None
|
max_entries = None
|
||||||
if should_display_hotness:
|
if self.should_display_hotness:
|
||||||
max_entries = args.max_hottest_remarks_on_index
|
max_entries = self.max_hottest_remarks_on_index
|
||||||
|
|
||||||
for i, remark in enumerate(all_remarks[:max_entries]):
|
for i, remark in enumerate(all_remarks[:max_entries]):
|
||||||
if not suppress(remark):
|
if not suppress(remark):
|
||||||
@ -201,11 +203,11 @@ class IndexRenderer:
|
|||||||
</html>''', file=self.stream)
|
</html>''', file=self.stream)
|
||||||
|
|
||||||
|
|
||||||
def _render_file(source_dir, output_dir, ctx, entry):
|
def _render_file(source_dir, output_dir, ctx, no_highlight, entry):
|
||||||
global context
|
global context
|
||||||
context = ctx
|
context = ctx
|
||||||
filename, remarks = entry
|
filename, remarks = entry
|
||||||
SourceFileRenderer(source_dir, output_dir, filename).render(remarks)
|
SourceFileRenderer(source_dir, output_dir, filename, no_highlight).render(remarks)
|
||||||
|
|
||||||
|
|
||||||
def map_remarks(all_remarks):
|
def map_remarks(all_remarks):
|
||||||
@ -227,7 +229,9 @@ def generate_report(all_remarks,
|
|||||||
file_remarks,
|
file_remarks,
|
||||||
source_dir,
|
source_dir,
|
||||||
output_dir,
|
output_dir,
|
||||||
|
no_highlight,
|
||||||
should_display_hotness,
|
should_display_hotness,
|
||||||
|
max_hottest_remarks_on_index,
|
||||||
num_jobs,
|
num_jobs,
|
||||||
should_print_progress):
|
should_print_progress):
|
||||||
try:
|
try:
|
||||||
@ -238,7 +242,7 @@ def generate_report(all_remarks,
|
|||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
_render_file_bound = functools.partial(_render_file, source_dir, output_dir, context)
|
_render_file_bound = functools.partial(_render_file, source_dir, output_dir, context, no_highlight)
|
||||||
if should_print_progress:
|
if should_print_progress:
|
||||||
print('Rendering HTML files...')
|
print('Rendering HTML files...')
|
||||||
optpmap.pmap(_render_file_bound,
|
optpmap.pmap(_render_file_bound,
|
||||||
@ -250,13 +254,13 @@ def generate_report(all_remarks,
|
|||||||
sorted_remarks = sorted(optrecord.itervalues(all_remarks), key=lambda r: (r.Hotness, r.File, r.Line, r.Column, r.PassWithDiffPrefix, r.yaml_tag, r.Function), reverse=True)
|
sorted_remarks = sorted(optrecord.itervalues(all_remarks), key=lambda r: (r.Hotness, r.File, r.Line, r.Column, r.PassWithDiffPrefix, r.yaml_tag, r.Function), reverse=True)
|
||||||
else:
|
else:
|
||||||
sorted_remarks = sorted(optrecord.itervalues(all_remarks), key=lambda r: (r.File, r.Line, r.Column, r.PassWithDiffPrefix, r.yaml_tag, r.Function))
|
sorted_remarks = sorted(optrecord.itervalues(all_remarks), key=lambda r: (r.File, r.Line, r.Column, r.PassWithDiffPrefix, r.yaml_tag, r.Function))
|
||||||
IndexRenderer(args.output_dir, should_display_hotness).render(sorted_remarks)
|
IndexRenderer(output_dir, should_display_hotness, max_hottest_remarks_on_index).render(sorted_remarks)
|
||||||
|
|
||||||
shutil.copy(os.path.join(os.path.dirname(os.path.realpath(__file__)),
|
shutil.copy(os.path.join(os.path.dirname(os.path.realpath(__file__)),
|
||||||
"style.css"), output_dir)
|
"style.css"), output_dir)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
def main():
|
||||||
parser = argparse.ArgumentParser(description=desc)
|
parser = argparse.ArgumentParser(description=desc)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'yaml_dirs_or_files',
|
'yaml_dirs_or_files',
|
||||||
@ -273,7 +277,7 @@ if __name__ == '__main__':
|
|||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--jobs',
|
'--jobs',
|
||||||
'-j',
|
'-j',
|
||||||
default=cpu_count(),
|
default=None,
|
||||||
type=int,
|
type=int,
|
||||||
help='Max job count (defaults to %(default)s, the current CPU count)')
|
help='Max job count (defaults to %(default)s, the current CPU count)')
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
@ -301,6 +305,10 @@ if __name__ == '__main__':
|
|||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--demangler',
|
'--demangler',
|
||||||
help='Set the demangler to be used (defaults to %s)' % optrecord.Remark.default_demangler)
|
help='Set the demangler to be used (defaults to %s)' % optrecord.Remark.default_demangler)
|
||||||
|
|
||||||
|
# Do not make this a global variable. Values needed to be propagated through
|
||||||
|
# to individual classes and functions to be portable with multiprocessing across
|
||||||
|
# Windows and non-Windows.
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
print_progress = not args.no_progress_indicator
|
print_progress = not args.no_progress_indicator
|
||||||
@ -321,6 +329,11 @@ if __name__ == '__main__':
|
|||||||
file_remarks,
|
file_remarks,
|
||||||
args.source_dir,
|
args.source_dir,
|
||||||
args.output_dir,
|
args.output_dir,
|
||||||
|
args.no_highlight,
|
||||||
should_display_hotness,
|
should_display_hotness,
|
||||||
|
args.max_hottest_remarks_on_index,
|
||||||
args.jobs,
|
args.jobs,
|
||||||
print_progress)
|
print_progress)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
@ -41,7 +41,7 @@ def pmap(func, iterable, processes, should_print_progress, *args, **kwargs):
|
|||||||
_total = multiprocessing.Value('i', len(iterable))
|
_total = multiprocessing.Value('i', len(iterable))
|
||||||
|
|
||||||
func_and_args = [(func, arg, should_print_progress,) for arg in iterable]
|
func_and_args = [(func, arg, should_print_progress,) for arg in iterable]
|
||||||
if processes <= 1:
|
if processes == 1:
|
||||||
result = map(_wrapped_func, func_and_args, *args, **kwargs)
|
result = map(_wrapped_func, func_and_args, *args, **kwargs)
|
||||||
else:
|
else:
|
||||||
pool = multiprocessing.Pool(initializer=_init,
|
pool = multiprocessing.Pool(initializer=_init,
|
||||||
|
Loading…
Reference in New Issue
Block a user