This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: calloc = malloc + memset
- From: Marc Glisse <marc dot glisse at inria dot fr>
- To: Andi Kleen <andi at firstfloor dot org>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Mon, 23 Jun 2014 22:14:25 +0200 (CEST)
- Subject: Re: calloc = malloc + memset
- Authentication-results: sourceware.org; auth=none
- References: <alpine dot DEB dot 2 dot 02 dot 1402282337290 dot 27023 at stedding dot saclay dot inria dot fr> <874mzb8p84 dot fsf at tassilo dot jf dot intel dot com> <alpine dot DEB dot 2 dot 10 dot 1406232053390 dot 2057 at laptop-mg dot saclay dot inria dot fr> <20140623193750 dot GT5714 at two dot firstfloor dot org>
On Mon, 23 Jun 2014, Andi Kleen wrote:
I would prefer to not do it.
For the sake of micro benchmarks?
I'm not sure it has a lot of benefit.
It has a non-zero benefit.
If you want to keep it please make sure there is an easy way to turn
it off.
Any of these flags works:
-fdisable-tree-strlen
-fno-builtin-malloc
-fno-builtin-memset (assuming you wrote 'memset' explicitly in your code)
-fno-builtin
-ffreestanding
-O1
-Os
In the code, you can hide that the pointer passed to memset is the one
returned by malloc by storing it in a volatile variable, or any other
trick to hide from the compiler that we are doing memset(malloc(n),0,n).
--
Marc Glisse