/optview2

User-oriented fork of LLVM's opt-viewer

Primary LanguagePython

optview2 - User-oriented fork of LLVM's opt-viewer

In the beginning, Adam Nemet created the opt-viewer python script family, as part of LLVM. He presented it at the 2016 LLVM Developers’ Meeting, and lo it was good.

In a nutshell (watch the talk!) it is a tool for collecting optimization remarks generated by clang -fsave-optimization-record, and displaying them beautifully integrated into htmls of the source files.

However, it was explicitly designed for use by compiler writers wishing to investigate and imporve optimization code, with a mention of future adaptation for usage by developers wishing to understand and improve their application's optimization.

That adaptation never happened - hence the birth of optview2. We aim to make this wonderful optimization data accessible and actionable by developers.

Main changes

  1. Ignore system headers (all files outside the given source root)
  2. Collect only optimization failures,
  3. Display in index.html only a single entry per type/source loc
  4. Replace ‘pass’ with ‘optimization name’
  5. Make the index table sortable & resizable (Thanks Ilan Ben-Hagai)
  6. Use abridged func names

Project management

I don't see any potential compatibility considerations now or in the future, and these are essentially only 5 python scripts and some html+javascript - so at this point there won't be any versioning or releases structure.

Just download and use - and please report any problems you come across.

Usage examples

First, build your C/C++ project with Clang + -fsave-optimization-record. Note that by default this generates YAMLs alongside the obj files. Then -

Basic usage:

./optview2/opt-viewer.py --output-dir <HTMLs destination> --source-dir <source location> <YAMLs location>

Parallelize to 10 jobs:

./optview2/opt-viewer.py -j10 --output-dir <> --source-dir <> <>