lkml.org 
[lkml]   [2005]   [Sep]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: p = kmalloc(sizeof(*p), )
    On Sun, Sep 18, 2005 at 03:25:39PM -0700, Linus Torvalds wrote:
    >
    >
    > On Sun, 18 Sep 2005, Al Viro wrote:
    > >
    > > BTW, for some idea of how hard does it actually blow
    >
    > Well, to be slightly more positive: it's not a very easy feature to do
    > properly.
    >
    > The thing about "(cast) { .. }" initializers is that they aren't just
    > initializers: they really are local objects that can be used any way you
    > want to. So in the _generic_ case, gcc does exactly the right thing: it
    > introduces a local object that is filled in with the initializer.

    Of course. It's not a question of local object being semantically correct.

    Forget for a minute about compound literals; consider

    {
    some_type foo = expression; /* doesn't use bar */
    bar = foo;
    }

    That's exactly what happens here. What does _not_ happen is elimination
    of foo. Note that all tricky cases happen when we take an address of
    our object or of some part of it. E.g. (struct foo){...}.scalar_field is
    happily optimized to <evaluate all members of initializer, memorizing the
    result for initializer if our field><use the memorized result>.

    What's happening might be (and no, I haven't looked into the gcc codegenerator
    yet) as simple as too early conversion of assignment to memcpy() call, losing
    the "we don't really use the address of this sucker after initialization"
    in process.
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2005-09-19 01:10    [W:2.690 / U:0.824 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site