Re: calloc.... Why?

From: JKop (NULL_at_NULL.NULL)
Date: 07/20/04


Date: Tue, 20 Jul 2004 12:30:03 GMT

tom_usenet posted:

> And using references doesn't make the optimizer's job any
easier IMHO.
> But it's likely that both versions will generate
identical code when
> inlined in the same context.
>
> Tom

It's not optimization at all, it's simply what inline
functions are all about. When a function is "outline",
arguments have to be passed to it in a certain way (stack
and registers), but when the function's inline, the stack
and registers aren't bothered with. So... with an inline
function; if you use const references, the compiler has no
optimation to do, it simply uses the objects in the calling
function. But if the arguments are by-value, then the
compiler actually would have to do an optimization to
realize that it can use the objects from the calling
function. Alternatively you could pass by-value and have
the objects const in the inline function, then the compiler
would know to use the objects from the calling function. I
prefer the const references, as it's very clear what's
going on.

-JKop



Relevant Pages

  • Re: Visual C++ 6.0 Compiler Problem with Optimizations Switched On
    ... inline means that you ask the compiler to replace all function calls to ... ReturnInt1 with the actual code in the function. ... optimization if the function is very small, and called lots of times in a ... the inline keyword is only a suggestion though. ...
    (microsoft.public.vc.language)
  • Re: Short-circuiting the optimizer
    ... Steve Richfie1d wrote: ... side effects on such optimization so that it wouldn't be performed, ... function was inlined, the compiler would then be forced not to inline ... That assumption simply cannot be made unless the compiler has verified, ...
    (comp.arch.arithmetic)
  • Re: copy ctor question
    ... In such cases the compiler can't inline the call ... it uses the virtual calling ... > copy of the classes vtable injected into the object file too. ...
    (comp.lang.cpp)
  • Re: When scrubbing secrets in memory doesnt work
    ... What compiler version/flags, if any does ... gcc 3 and later are well able to do this optimization, ... that the compiler already has a body to inline, so you don't have to provide ... An interesting corner case exists in gcc - often, ...
    (Bugtraq)
  • Re: [PATCH 10/23] make atomic_read() and atomic_set() behavior consistent on ia64
    ... Part of the motivation for using inline functions was to expose places where we've been lazy, ... It would seem that inlining changed the optimization behavior of the compiler. ... Since the macro version didn't change anything, ... Converting from a macro to an inline shouldn't really change anything in this case, except perhaps for how the compiler optimizes it. ...
    (Linux-Kernel)