Re: Experiences using "register"



Ioannis Vranos wrote:

Harald van Dijk wrote:
On Sun, 30 Mar 2008 18:01:45 +0300, Ioannis Vranos wrote:
Harald van Dijk wrote:
On Sun, 30 Mar 2008 16:55:58 +0200, Richard wrote:
Ioannis Vranos <ivranos@xxxxxxxxxxxxxxxxxxxxxxxxx> writes:
Willem wrote:
You're arguing in circles again.
Why should 'register' be used only when it has minimal effect on
the code ?
Why "inline" should be used with small functions only?
Because it adversely affects code size is one thing I can think of
...
If the function is huge, but it's only called from one place,
inlining may even decrease the code size.
Still, you don't know how many times it will be called in the
future, so it is a bad practice.

Yes, I do, if it's something like the main loop of an event-driven
program, or library initialisation. It doesn't make any sense to call
that more than once, or from different locations.


This reminds me something I have read elsewhere. Something like "no
rule is so general that it has no exceptions".

In any case, how much size will you save if you make this one-called
function inlined? The same minus a function call (an address) in the
automatic storage.

The main purpose of inline is to take away the function call and return
overhead, and this can make sense only for a function that is very
small and finishes very quickly, and is called often, or if the
performance of that function is critical. Otherwise the code for the
function is going to swamp any benefit from shaving of the call/return
instructions. Using inline for affecting code size is, IMO, misusing
it. Again the standard inline keyword is like register: just a hint. A
macro is going to give you an assurance of inlining at the cost of loss
of parameter type checking, or you might try compiler specific options
to force inlining of certain functions.

.



Relevant Pages

  • Re: Best charting package
    ... You're right about the property inlining, but it is present only in the ... ..NET framework 2.0 and to a certain level - for example having a simple ... Inline functions / properties are badly missing. ... MSVC would ignore the register ...
    (microsoft.public.dotnet.framework.windowsforms.controls)
  • Re: inline
    ... normal inline function definition - Stand-alone object code is always ... Where will be the practical use/application of these ('static inline ... Most compilers are smart about inlining and only use inline as a hint, ... register allocators work better on smaller functions with low register ...
    (comp.arch.embedded)
  • Re: GCC 3.4 and broken inlining.
    ... But, like the `register' keyword, it's just a hint. ... but you can take the address of an inline ... The issue with inlining that makes it important for the compiler to ...
    (Linux-Kernel)
  • Re: inline functions not inlined
    ... occur if the inline function is defined within the same file that it is ... Maybe it's an added complexity like 'register' which the language ... I suspect that modern compilers aren't as good at automatically ... inlining functions as they are at assigning variables to registers, ...
    (comp.lang.c)
  • Re: [patch] measurements, numbers about CONFIG_OPTIMIZE_INLINING=y impact
    ... So take your complaint about gcc's decision to inline functions called ... The problem with that is that the kernel _isn't_ a normal app. ... And outside of those kinds of very rare niches, big kernel dumps simply ... Sure, shrinking code is good for I$, but on the other hand inlining ...
    (Linux-Kernel)