Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1364980

Re: [PATCH 2/2] include/linux: apply __malloc attribute

From Rasmus Villemoes <linux@rasmusvillemoes.dk>
Newsgroups linux.kernel
Subject Re: [PATCH 2/2] include/linux: apply __malloc attribute
Date 2016-03-26 20:10 +0100
Message-ID <rh1KW-57a-9@gated-at.bofh.it> (permalink)
References <rg0Hg-2od-5@gated-at.bofh.it> <rg0Hh-2od-23@gated-at.bofh.it> <rgm54-OZ-17@gated-at.bofh.it>
Organization D03

Show all headers | View raw


On Thu, Mar 24 2016, Andrew Morton <akpm@linux-foundation.org> wrote:

> On Thu, 24 Mar 2016 00:42:32 +0100 Rasmus Villemoes <linux@rasmusvillemoes.dk> wrote:
>
>> Attach the malloc attribute to a few allocation functions. This helps
>> gcc generate better code by telling it that the return value doesn't
>> alias any existing pointers (which is even more valuable given the
>> pessimizations implied by -fno-strict-aliasing).
>> 
> Shaves 6 bytes off my 1MB i386 defconfig vmlinux.  Winner!

Well, the full bloat-o-meter summary is

add/remove: 0/0 grow/shrink: 72/155 up/down: 1165/-1674 (-509)

which sure still isn't much, but this isn't (just) about saving a few
bytes, but more about allowing gcc to generate better code; sometimes by
not having to reload, but also by enabling it to reorder instructions
(e.g. hoisting a load above a store) - the simple example was chosen
because it was very easy to see the relationship between the source and
the generated code.

Anyway, thanks for picking them up.

Rasmus

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH 1/2] compiler.h: add support for malloc attribute Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2016-03-24 00:50 +0100
  [PATCH 2/2] include/linux: apply __malloc attribute Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2016-03-24 00:50 +0100
    Re: [PATCH 2/2] include/linux: apply __malloc attribute Andrew Morton <akpm@linux-foundation.org> - 2016-03-24 23:40 +0100
      Re: [PATCH 2/2] include/linux: apply __malloc attribute Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2016-03-26 20:10 +0100

csiph-web