[Patch] Remove workaround for copy_backward
Phil Edwards
phil@jaj.com
Mon Sep 29 16:39:00 GMT 2003
On Mon, Sep 29, 2003 at 06:13:01PM +0200, Gabriel Dos Reis wrote:
>
> Because C and C++ have genuire separate compilation models :-). The
> above example is the function definition, and in that context it is
> clear that the last argument is not used. However, a call to foo
> needs only to have its prototype available. And prototype does say
> nothing about used parameters.
Exactly. Which is wh- ah, I see the disconnect. It all depends on who's
responsible for loading the registers. If it's the caller, as in your
model, there's no way to know and the register must be loaded. If the
called fuction is responsible for loading its arguments from known relative
stack addresses, the compiler can generate code that safely ignores the
unused arguments.
I doubt that our compiler tries to perform that particular "optimization"
on those platforms for which it is appropriate. It may not even be a real
win, because (IIRC) the appropriate platforms are not register-starved to
begin with.
> The case for parameters of user-defined types is different. You
> cannot make a call with arguments of incomplete types. That means
> that at the call site, the compiler knows which arguments whose types
> are empty POD class types. So it can make the appropriate decision
> (of not allocating registers for them).
Yep. It's a wonderful world.
--
Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it.
- Brian W. Kernighan
More information about the Libstdc++
mailing list