This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] un-#ifdef GATHER_STATISTICS
- From: Markus Trippelsdorf <markus at trippelsdorf dot de>
- To: Steven Bosscher <stevenb dot gcc at gmail dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, Richard Guenther <richard dot guenther at gmail dot com>
- Date: Tue, 24 Jul 2012 18:21:07 +0200
- Subject: Re: [patch] un-#ifdef GATHER_STATISTICS
- References: <CABu31nM_NPX2KbPWCH2aHgdQFWmbmm=S+h+cqHjHE4MSMAeU1w@mail.gmail.com>
On 2012.07.23 at 19:01 +0200, Steven Bosscher wrote:
> Hello,
>
> This large patch makes GATHER_STATISTICS always take a value, 0
> (disabled) or 1 (enabled), and turns all related #ifdef code into
> conditional branches.
>
> This slightly increases the data section of cc1, but only marginally.
> There is no impact on compile time, because all tests are simply
> optimized away if GATHER_STATISTICS is 0.
>
> The benefit is that this improves the coverage of this code, and less
> #ifdef'ed code (which is IMHO a Good Thing).
>
>...
>
> Index: alloc-pool.c
> ===================================================================
> --- alloc-pool.c (revision 189784)
> +++ alloc-pool.c (working copy)
> @@ -62,8 +62,6 @@ typedef struct allocation_object_def
> static ALLOC_POOL_ID_TYPE last_id;
> #endif
>
> -#ifdef GATHER_STATISTICS
> -
> /* Store information about each particular alloc_pool. Note that this
> will underestimate the amount the amount of storage used by a small amount:
> 1) The overhead in a pool is not accounted for.
> @@ -123,7 +121,6 @@ alloc_pool_descriptor (const char *name)
> (*slot)->name = name;
> return *slot;
> }
> -#endif
>
> /* Create a pool of things of size SIZE, with NUM in each block we
> allocate. */
> @@ -133,9 +130,6 @@ create_alloc_pool (const char *name, siz
> {
> alloc_pool pool;
> size_t header_size;
> -#ifdef GATHER_STATISTICS
> - struct alloc_pool_descriptor *desc;
> -#endif
>
> gcc_checking_assert (name);
>
> @@ -146,10 +140,11 @@ create_alloc_pool (const char *name, siz
> /* Now align the size to a multiple of 4. */
> size = align_eight (size);
>
> -#ifdef ENABLE_CHECKING
> - /* Add the aligned size of ID. */
> - size += offsetof (allocation_object, u.data);
> -#endif
> + if (ENABLE_CHECKING)
> + {
> + /* Add the aligned size of ID. */
> + size += offsetof (allocation_object, u.data);
> + }
The change above causes a build failure with --enable-checking=release:
x86_64-pc-linux-gnu-gcc -c -g -O2 -DIN_GCC -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wmissing-format-attribute -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Wold-style-definition -Wc++-compat -DHAVE_CONFIG_H -I. -I. -I../../gcc/gcc -I../../gcc/gcc/. -I../../gcc/gcc/../include -I../../gcc/gcc/../libcpp/include -I../../gcc/gcc/../libdecnumber -I../../gcc/gcc/../libdecnumber/bid -I../libdecnumber ../../gcc/gcc/alloc-pool.c -o alloc-pool.o
../../gcc/gcc/alloc-pool.c: In function â??create_alloc_poolâ??:
../../gcc/gcc/alloc-pool.c:143:7: error: â??ENABLE_CHECKINGâ?? undeclared (first use in this function)
if (ENABLE_CHECKING)
^
../../gcc/gcc/alloc-pool.c:143:7: note: each undeclared identifier is reported only once for each function it appears in
--
Markus