<div dir="auto"><div><br><br><div class="gmail_quote"><div dir="ltr">On Thu, Aug 9, 2018, 11:50 AM Sebastian Huber <<a href="mailto:sebastian.huber@embedded-brains.de">sebastian.huber@embedded-brains.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">----- Am 6. Aug 2018 um 21:14 schrieb joel <a href="mailto:joel@rtems.org" target="_blank" rel="noreferrer">joel@rtems.org</a>:<br>
[...]<br>
> We looked at a lot of generated assembly. Sometimes we would see<br>
> large methods being inlined multiple times. This would increase the overall<br>
> size of an RTEMS application. But size is not the only impact of inlining.<br>
> If an inlined method has one or more if's in it, then the branch paths<br>
> it includes are introduced EVERYWHERE it is inlined. When we<br>
> had _Thread_Dispatch_enable, I recall it was used > 100 times and<br>
> includes a branch in it. There was a build option to not inline this<br>
> routine to avoid needing to add over 100 test cases.<br>
[...]<br>
<br>
I had a look at the _Thread_Dispatch_enable() code and was a bit surprised that GCC generates a stack frame in this function.  This turned out as a bug in the function. Do you find it? I will fix it tomorrow.<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">Chris and I were just counting instructions and branch paths. But I do recall seeing ret and restore. That's a hint it is really too big to inline.</div><div dir="auto"><br></div><div dir="auto">Perhaps the check for yes/no to dispatch should be inlined and the rest in a method. This is how it was historically.</div><div dir="auto"><br></div><div dir="auto">  If (--dispatch disable level)</div><div dir="auto">    Call thread dispatch</div><div dir="auto"><br></div><div dir="auto">But this only avoided the call on non-interrupt cases so not inlining at all really wasn't a hit. I suspect the same now. Nearly all the time it calls a subroutine anyway and 3K of code is added uselessly. </div><div dir="auto"><br></div><div dir="auto">Look at it holistically. What is executed when it is a different is not inlined?</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Before we start to turn inline functions into non-inline functions we should create a benchmark program (or more). We should look at the overall code size changes and the local code changes.<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">We were relying on checking size and our benchmarks before. </div><div dir="auto"><br></div><div dir="auto">One metric was the size of the code we were analysing for coverage. That's directly in the coverage reports.</div><div dir="auto"><br></div><div dir="auto">Another metric when a lot of branch paths have been inlined is the number of uncovered ranges. When you investigate and realize they are from an inlineethod used in N places, it is clearly something to.look at.</div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
</blockquote></div></div></div>