diff options
author | Brian Gesiak <modocache@gmail.com> | 2017-06-29 18:47:31 +0000 |
---|---|---|
committer | Brian Gesiak <modocache@gmail.com> | 2017-06-29 18:47:31 +0000 |
commit | d3a05713012f33bd36670ea104788822d24e971d (patch) | |
tree | fd117ee2c0ebe7f880185ba8cd9e36a07bc96cc7 /llvm/utils | |
parent | 7272f06a7027816e06a04559655461b60da58567 (diff) | |
download | bcm5719-llvm-d3a05713012f33bd36670ea104788822d24e971d.tar.gz bcm5719-llvm-d3a05713012f33bd36670ea104788822d24e971d.zip |
[opt-viewer] Python 3 support in opt-viewer.py
Summary:
Minor changes that allow opt-stats.py to support both Python 2 and 3.
In addition to the same dictionary iterator changes that were necessary
in https://reviews.llvm.org/D34564, this diff also:
* Explcitly converts strings to bytes when reading from and writing to stdin
and stdout.
* No longer uses dictionaries as a sort key for optimization remarks.
Dictionary sort order in Python 2 is pretty esoteric anyway, so it's
not clear that the additional sorting had a benefit for end users
(for details, https://stackoverflow.com/a/3484456/679254 is a good
resource on Python 2 dictionary sort order).
Reviewers: anemet, davidxl
Reviewed By: anemet
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D34647
llvm-svn: 306720
Diffstat (limited to 'llvm/utils')
-rwxr-xr-x | llvm/utils/opt-viewer/opt-viewer.py | 6 | ||||
-rw-r--r-- | llvm/utils/opt-viewer/optrecord.py | 5 |
2 files changed, 6 insertions, 5 deletions
diff --git a/llvm/utils/opt-viewer/opt-viewer.py b/llvm/utils/opt-viewer/opt-viewer.py index 88a613b78a7..394a472b15e 100755 --- a/llvm/utils/opt-viewer/opt-viewer.py +++ b/llvm/utils/opt-viewer/opt-viewer.py @@ -169,7 +169,7 @@ def _render_file(source_dir, output_dir, ctx, entry): def map_remarks(all_remarks): # Set up a map between function names and their source location for # function where inlining happened - for remark in all_remarks.itervalues(): + for remark in optrecord.itervalues(all_remarks): if isinstance(remark, optrecord.Passed) and remark.Pass == "inline" and remark.Name == "Inlined": for arg in remark.Args: caller = arg.get('Caller') @@ -190,9 +190,9 @@ def generate_report(pmap, all_remarks, file_remarks, source_dir, output_dir, sho pmap(_render_file_bound, file_remarks.items()) if should_display_hotness: - sorted_remarks = sorted(all_remarks.itervalues(), key=lambda r: (r.Hotness, r.File, r.Line, r.Column, r.__dict__), 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: - sorted_remarks = sorted(all_remarks.itervalues(), key=lambda r: (r.File, r.Line, r.Column, r.__dict__)) + 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).render(sorted_remarks) shutil.copy(os.path.join(os.path.dirname(os.path.realpath(__file__)), diff --git a/llvm/utils/opt-viewer/optrecord.py b/llvm/utils/opt-viewer/optrecord.py index 6dc1a32e536..072ae0991b2 100644 --- a/llvm/utils/opt-viewer/optrecord.py +++ b/llvm/utils/opt-viewer/optrecord.py @@ -42,8 +42,9 @@ else: def demangle(name): with p_lock: - p.stdin.write(name + '\n') - return p.stdout.readline().rstrip() + p.stdin.write((name + '\n').encode('utf-8')) + p.stdin.flush() + return p.stdout.readline().rstrip().decode('utf-8') def html_file_name(filename): |