<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi everyone,<div class=""><br class=""></div><div class="">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.</div><div class=""><br class=""></div><div class="">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.</div><div class=""><br class=""></div><div class="">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:</div><div class=""><br class=""></div><div class="">1) Which functions grew the most in size between one compilation and another compilation</div><div class="">2) Which functions were/were not inlined between compilations (and similar insights into other passes)</div><div class="">3) Which compiler passes caused the largest increases in each function</div><div class=""><br class=""></div><div class="">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:</div><div class=""><br class=""></div><div class=""><a href="https://reviews.llvm.org/D63306" class="">https://reviews.llvm.org/D63306</a></div><div class=""><br class=""></div><div class="">The tool in the patch works like this:</div><div class=""><br class=""></div><div class="">$ ./sizediff old_version_of_program new_version_of_program</div><div class=""><br class=""></div><div class="">And it produces output like this:</div><div class=""><br class=""></div><div class="">function_name old_instruction_count new_instruction_count delta</div><div class=""><br class=""></div><div class="">This output can tell me the following things:</div><div class=""><br class=""></div><div class="">- Which functions were not present in old_version_of_program (they have a size of 0)</div><div class="">- Which functions were not present in new_version_of_program (same idea)</div><div class="">- Which functions grew the most</div><div class="">- Which functions shrunk the most</div><div class=""><br class=""></div><div class="">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:</div><div class=""><br class=""></div><div class=""><a href="https://hastebin.com/hucexocuxi.md" class="">https://hastebin.com/hucexocuxi.md</a></div><div class=""><br class=""></div><div class="">If anyone is interested, feel free to try it out/review/etc. I think that a tool like this would be quite useful. :)</div><div class=""><br class=""></div><div class="">- Jessica</div></body></html>