Re: [PATCH] Use __attribute__((malloc)) for gcc 3.2

Andi Kleen (ak@muc.de)
Mon, 30 Sep 2002 02:29:15 +0200


On Mon, Sep 30, 2002 at 02:11:10AM +0200, David S. Miller wrote:
> From: Christoph Hellwig <hch@infradead.org>
> Date: Sun, 29 Sep 2002 18:26:43 +0100
>
> BTW, do you have any stats on the better optimization?
>
> Unlikely since we disable strict aliasing on the gcc command
> line which is why I think this suggested __malloc thing is
> utterly pointless.

My understanding of it is: Please correct me if I'm wrong [i haven't
verified this with tree dumps]

-fno-strict-aliasing tells each pointer that it can alias with everything
else (puts it in alias set 0)

__attribute__((malloc)) overwrites this so that the compiler knows that
this particular pointer that has been returned (puts it into an own
alias set again and overwrites the -fno-strict-aliasing default)

Another way to overwrite it would be restrict, but nobody uses that
currently. May make sense to add it to compile compiler version checked
macros too, so that it can be safely used.

Then it would be actually possible to write functions that get optimized
this way. I'm aware that the aliasing stuff mostly helps with array walks
and loops, which are not that common in the kernel, but it could be still
useful.

-Andi
-
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/