summaryrefslogtreecommitdiffstats
path: root/llvm/tools/opt-viewer/opt-viewer.py
Commit message (Collapse)AuthorAgeFilesLines
* Revert Autogenerate the shebang lines for tools/opt-viewerReid Kleckner2019-08-271-0/+382
| | | | | | | | | | This reverts r369486 (git commit 8d18384809957cc923752e10a86adab129e3df48) The opt-viewer tests don't pass after this change, and fixing them isn't trivial. opt-viewer.py imports optmap, which requires adjusting pythonpath, which is more work than I'm willing to do to fix forward. llvm-svn: 370095
* Autogenerate the shebang lines for tools/opt-viewerChris Bieneman2019-08-211-382/+0
| | | | | | | | | | | | | | | | | | | | | Summary: Since these files depend on the built python modules, they need to use the right python binary to run them. So use configure_file to set the right shebang line. Patch By: cbiesinger (Christian Biesinger) Reviewers: chandlerc, beanz, anemet Reviewed By: anemet Subscribers: compnerd, JDevlieghere, mgorny, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D65983 llvm-svn: 369486
* [opt-viewer] Add --filter option to select remarks for displaying.Florian Hahn2019-02-061-2/+7
| | | | | | | | | | | | | | | | | This allows limiting the displayed remarks to the ones with names matching the filter (regular) expression. Generating html pages for a larger project with optimization remarks can result in a huge HTML documents and using --filter allows to focus on a set of interesting remarks. Reviewers: hfinkel, anemet, thegameg, serge-sans-paille Reviewed By: anemet Differential Revision: https://reviews.llvm.org/D57827 llvm-svn: 353322
* [opt-viewer] Add javascript to expand/hide full message for multiline remarks.Florian Hahn2019-01-251-1/+32
| | | | | | | | | | | | | | | | | | | | | | | This patch adds support for displaying remarks with multiple lines. For such remarks, it creates a hidden div containing the message's lines except the first one in a <pre> tag. It also prepends a link (with '+' as text) to the regular remark line. This link can be used to show/hide the div containing the full remark. In combination with D57159, this allows for better displaying of multiline remarks in the html pages generated by opt-viewer. The Javascript is very simple and should be supported by any recent major browser. Reviewers: hfinkel, anemet, thegameg, serge-sans-paille Reviewed By: anemet Differential Revision: https://reviews.llvm.org/D57167 llvm-svn: 352223
* Python compat - no explicit reference to Python versionSerge Guelton2019-01-031-1/+1
| | | | | | | | Update documentation and shebang. Differential Revision: https://reviews.llvm.org/D56252 llvm-svn: 350327
* Python compat - decode/encode stringSerge Guelton2019-01-031-1/+4
| | | | | | Differential Revision: https://reviews.llvm.org/D56258 llvm-svn: 350320
* [opt-viewer] Set title for the source pagesAdam Nemet2018-02-261-1/+3
| | | | llvm-svn: 326125
* opt-viewer: output index firstAdam Nemet2018-02-261-7/+9
| | | | | | One can start looking at the index while the pages are still generating llvm-svn: 326123
* Fix some opt-viewer test issues and disable on Windows.Zachary Turner2018-01-051-11/+24
| | | | | | Differential Revision: https://reviews.llvm.org/D41784 llvm-svn: 321905
* [opt-viewer] Render utf-8 characters properly in the generated HTMLAdam Nemet2017-12-141-0/+2
| | | | llvm-svn: 320729
* [opt-viewer] Support unicode characters in function namesAdam Nemet2017-12-141-9/+13
| | | | | | | | | | This is a Swift feature. The output stream for the index page and the source HTML page is utf-8 now. The next patch will add the HTML magic to properly render these characters in the browser. llvm-svn: 320725
* [opt-viewer] Suppress noisy Swift remarksAdam Nemet2017-12-061-2/+11
| | | | | | | | | Most likely, this is not how we want to handle this in the long term. This code should probably be in the Swift repo and somehow plugged into the opt-viewer. This is still however very experimental at this point so I don't want to over-engineer it at this point. llvm-svn: 319902
* Add opt-viewer testingAdam Nemet2017-11-291-10/+24
| | | | | | | | | | | | | | | | | | | | Detects whether we have the Python modules (pygments, yaml) required by opt-viewer and hooks this up to REQUIRES. This fixes https://bugs.llvm.org/show_bug.cgi?id=34129 (the lack of opt-viewer testing). It's also related to https://github.com/apple/swift/pull/12938 and the idea is to expose LLVM_HAVE_OPT_VIEWER_MODULES to the Swift cmake. Differential Revision: https://reviews.llvm.org/D40202 Fixes since the first commit: 1. Disable syntax highlighting as different versions of pygments generate different HTML 2. Use llvm-cxxfilt from the build llvm-svn: 319324
* Revert "Add opt-viewer testing"Adam Nemet2017-11-291-19/+10
| | | | | | | | This reverts commit r319188. Breaks when c++filt is not available. llvm-svn: 319262
* Add opt-viewer testingAdam Nemet2017-11-281-10/+19
| | | | | | | | | | | | | | | Detects whether we have the Python modules (pygments, yaml) required by opt-viewer and hooks this up to REQUIRES. This fixes https://bugs.llvm.org/show_bug.cgi?id=34129 (the lack of opt-viewer testing). It's also related to https://github.com/apple/swift/pull/12938 and the idea is to expose LLVM_HAVE_OPT_VIEWER_MODULES to the Swift cmake. Differential Revision: https://reviews.llvm.org/D40202 llvm-svn: 319188
* [opt-viewer] Fix option nameAdam Nemet2017-11-271-1/+1
| | | | llvm-svn: 319072
* [opt-viewer] Truncate long remark text in source viewAdam Nemet2017-11-141-7/+11
| | | | | | | | | The table is changed to fixed layout[1] and the lines use ellipses if they would overflow their cell. [1] https://css-tricks.com/fixing-tables-long-strings/ llvm-svn: 318136
* [opt-viewer] With hotness only show max 1000 entries on the index pageAdam Nemet2017-11-141-3/+14
| | | | | | Adjustable with an option. llvm-svn: 318135
* [opt-viewer] Don't Decode HTML bytes for Python 2Roman Lebedev2017-10-101-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: D36624 added some python3 compatibility. But that fix has a problem.. With python2 (which is specified by `#!/usr/bin/env python2.7`), if the env variables do not specify the UTF8, and the source file is UTF8 (contains non-ASCII symbols), then the `.decode('utf-8')` causes the following exception: ``` Reading YAML files... Rendering HTML files... 8 of 41Traceback (most recent call last): File "/build/llvm/tools/opt-viewer/opt-viewer.py", line 277, in <module> print_progress) File "/build/llvm/tools/opt-viewer/opt-viewer.py", line 213, in generate_report should_print_progress) File "/build/llvm/tools/opt-viewer/optpmap.py", line 45, in pmap result = map(_wrapped_func, func_and_args, *args, **kwargs) File "/build/llvm/tools/opt-viewer/optpmap.py", line 25, in _wrapped_func return func(argument) File "/build/llvm/tools/opt-viewer/opt-viewer.py", line 174, in _render_file SourceFileRenderer(source_dir, output_dir, filename).render(remarks) File "/build/llvm/tools/opt-viewer/opt-viewer.py", line 125, in render self.render_source_lines(self.source_stream, line_remarks) File "/build/llvm/tools/opt-viewer/opt-viewer.py", line 79, in render_source_lines </tr>'''.format(**locals()), file=self.stream) UnicodeEncodeError: 'ascii' codec can't encode character u'\xf4' in position 47: ordinal not in range(128) ``` This is similar to https://bugs.llvm.org/show_bug.cgi?id=33548, which was fixed by https://reviews.llvm.org/D37661 Unlike that fix, here, *removing* `.decode('utf-8')` actually fixes it. Since i assume that the original fix is needed, i simply made that fix conditional, since for python2 it actually breaks things. Reviewers: modocache, anemet Reviewed By: anemet Subscribers: fhahn, llvm-commits Differential Revision: https://reviews.llvm.org/D38289 llvm-svn: 315350
* Make find_opt_files varargAdam Nemet2017-09-291-1/+1
| | | | | | | This is slightly less verbose for the common case of a single build directory and more intuitive when using this API directly from the interpreter. llvm-svn: 314491
* [opt-viewer] Decode HTML bytes for Python 3Brian Gesiak2017-08-111-1/+4
| | | | | | | | | | | | | | | | | | | | | | | Summary: When using Python 3, `pygments.highlight()` returns a `bytes` object, not a `str`, causing the call to `str.replace` on the following line to fail with a runtime exception: `TypeError: 'str' does not support the buffer interface`. Decode the bytes into a string in order to fix the exception. Test Plan: Run `opt-viewer.py` with Python 3.4, and confirm no runtime error occurs when calling `str.replace`. Reviewers: anemet Reviewed By: anemet Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D36624 llvm-svn: 310741
* [opt-viewer] Reduce memory consumption by another 20-25%Adam Nemet2017-07-191-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | The Args field of the remark which consists of a list of mappings in YAML is translated into a list of (small) dicts on Python. An empty dict is 280 bytes on my system so we can save memory by using a tuple of tuples instead. Making a tuple of tuples rather than a list of tuples allows Args to be shared with the key of the remark. This is actually an even greater saving. (Keys are alive throughout the entire run in all_remarks.) Here are a few opt-stats runs with different input sizes while measuring heap usage with heapy. Avg remark size is simply estimated as heap-size / # of remarks: | # of files | 60 | 114 | 308 | 605 | 1370 | | # of remarks | 20K | 37K | 146K | 180K | 640K | | total file size (MB) | 22 | 51 | 219 | 202 | 1034 | |------------------------+------+------+------+------+------| | Avg remark size before | 4339 | 4792 | 4761 | 4096 | 4607 | | Avg remark size after | 3446 | 3641 | 3567 | 3146 | 3347 | | Rate | 0.79 | 0.76 | 0.75 | 0.77 | 0.73 | Differential Revision: https://reviews.llvm.org/D35611 llvm-svn: 308538
* [opt-viewer] Accept directories that are searched for opt.yaml filesAdam Nemet2017-07-171-2/+12
| | | | | | | | | | | | This allows to pass the build directory where all the opt.yaml files are rather than find | xargs which may invoke opt-viewer multiple times producing incomplete html output. The patch generalizes the same functionality from opt-diff. Differential Revision: https://reviews.llvm.org/D35491 llvm-svn: 308200
* [opt-viewer] Don't except when debug info is not available.Davide Italiano2017-07-131-1/+4
| | | | | | | | | | | For records without DebugLoc we simply skip the caller location in map_remarks. Fixes PR33764. Patch by Simon Whittaker! llvm-svn: 307880
* [opt-viewer] Move under tools, install itAdam Nemet2017-07-061-0/+259
We weren't installing opt-viewer and co before, this fixes the omission. I am also moving the tools from utils/ to tools/. I believe that this is more appropriate since these tools have matured greatly in the past year through contributions by multiple people (thanks!) so they are ready to become external tools. The tools are installed under <install>/share/opt-viewer/. I am *not* adding the llvm- prefix. If people feel strongly about adding that, this is probably a good time since the new location will require some mental adjustment anyway. Fixes PR33521 Differential Revision: https://reviews.llvm.org/D35048 llvm-svn: 307285
OpenPOWER on IntegriCloud