[llvm-dev] [RFC] Remarks-based code size analysis tool
Jessica Paquette via llvm-dev
llvm-dev at lists.llvm.org
Thu Jun 13 16:30:44 PDT 2019
Hi everyone,
I frequently find that I want to quickly find out which functions have changed the most in size when I compile a program with one version of the compiler and another version of the compiler.
Optimization remarks provide deeper insight into what the compiler does to individual functions during the compilation process. A tool based off of remarks would give us the means to say *exactly* what a pass did to a function during the compilation process. We also have remarks from the asm-printer which tell us the number of instructions in a function at any given time.
It’s now possible to access remarks through object files. So, I thought it would be an interesting experiment to write a C++ tool using the new remarks API to write a simple size tool. A size tool using remarks would be able to tell us about the following things:
1) Which functions grew the most in size between one compilation and another compilation
2) Which functions were/were not inlined between compilations (and similar insights into other passes)
3) Which compiler passes caused the largest increases in each function
I have a prototype for a size tool which accomplishes (1) using asm-printer remarks. (2) and (3) can be accomplished by searching for remarks corresponding to interesting passes and by searching for size-info remarks respectively. For now, I just decided to implement the minimum set of features for a useful tool. The patch is available here:
https://reviews.llvm.org/D63306 <https://reviews.llvm.org/D63306>
The tool in the patch works like this:
$ ./sizediff old_version_of_program new_version_of_program
And it produces output like this:
function_name old_instruction_count new_instruction_count delta
This output can tell me the following things:
- Which functions were not present in old_version_of_program (they have a size of 0)
- Which functions were not present in new_version_of_program (same idea)
- Which functions grew the most
- Which functions shrunk the most
For a concrete example of the output, here’s some output I got by compiling the stepanov_container benchmark for AArch64 with -Os and -O3 respectively:
https://hastebin.com/hucexocuxi.md <https://hastebin.com/hucexocuxi.md>
If anyone is interested, feel free to try it out/review/etc. I think that a tool like this would be quite useful. :)
- Jessica
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190613/cc3f2702/attachment.html>
More information about the llvm-dev
mailing list