<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Hi Jessica,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
We often have exactly the same problem:</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
> <span style="color: rgb(32, 31, 30); font-family: "Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif; font-size: 15px;">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.</span><br>
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Your tool looks very interesting and useful. I think we are very interested. In fact, I am looking at code-size problems at the moment, and will give it a try. I think we can help with the review too.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
FWIW, when I investigate code-size problems, I usually start looking at the final linked image (for context, that's mostly baremetal images). Unused sections and functions will be removed by the linker, which e.g. avoids unnecessary analysing them which may
happen when you only look at object files. I use a downstream tool for binaries that list the code-size per function. When I generate such a report for different images, I can easily diff them and see where codesize difference are the biggest. I then isolate
a function, compile it with debug and print-after-all, so that I can do a diff again where changes are introduced. And when image sizes are small, and library inclusion is thus relatively important, the linker in verbose mode telling me why and which objects
and functions are included is extremely useful too.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Cheers,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Sjoerd.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div id="appendonsend"></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> llvm-dev <llvm-dev-bounces@lists.llvm.org> on behalf of Jessica Paquette via llvm-dev <llvm-dev@lists.llvm.org><br>
<b>Sent:</b> 14 June 2019 00:30<br>
<b>To:</b> Jessica Paquette via llvm-dev<br>
<b>Subject:</b> [llvm-dev] [RFC] Remarks-based code size analysis tool</font>
<div> </div>
</div>
<div class="" style="word-wrap:break-word; line-break:after-white-space">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>
</div>
</body>
</html>