Re: [patch 00/2] improve .text size on gcc 4.0 and newer compilers

Mitchell Blank Jr
2006-01-06T01:48:44Z

Martin Bligh wrote:
> But we were just discussing here ... wouldn't it be worth moving
> "unlikely" sections of code completely out of line? If they were calls
> to separate functions, all this optimisation stuff could just work at a
> function level, and would be pretty trivial to do?

...assuming that they don't need to access many local variables. And don't
have any "goto" statements... and... etc, etc.

> we'd have
>
> if (unlikely(conditon)) {
> call_oh_shit();
> }
>
> __rarely_called void call_oh_shit()
> {
> do;
> some;
> stuff;
> BUG();
> error();
> oh_dear();
> }

As I described in my other mail on this thread, the _ideal_ solution would
be to tell the compiler that BUG() is a __rarely_called function (well, it's
a macro now but it could be made into an inline function) and let the
compiler figure the rest out without further annotation

> Moving that out of line would seem
> to make more difference to icache footprint to me than just cacheline
> packing functions.

Assuming "-funit-at-a-time" (which all archs will probably be using soon)
you'd probably get exactly the same opcodes either way.

-Mitch